Exemple #1
0
func HttpResponse(
	writer *bufio.Writer,
	status int,
	headers map[string]string,
	body io.Reader) {

	// send status
	statusLine := "HTTP/1.1 " +
		strconv.FormatInt(int64(status), 10) +
		" " +
		statusCodes[status] +
		"\r\n"

	writer.WriteString(statusLine)

	for name, value := range headers {
		writer.WriteString(name + ": " + value + "\r\n")
	}

	writer.WriteString("\r\n")

	writer.ReadFrom(body)
	writer.Flush()
}