go func() {
for req := range respChan {
content := make([]byte, 0, 1024*32)
content = append(content, []byte("HTTP1.1 200 OK
")...)
for k, v := range req.Response.Headers {
content = append(content, []byte(fmt.Sprintf("%s:%s
", k, v))...)
}
content = append(content, []byte("
")...)
content = append(content, req.Response.Content...)
fmt.Println(string(content[:]))
_, err := syscall.Write(int(req.Fd), content)
handleEpollError(err)
}
}()
I try to implement a http server by linux epoll, eventhing is ok but browser always keep waiting after server finish sending by socket until I interrupt the process. Should I send some terminate characters or do other terminate operation? Above is only the code writing http response by socket.