Skip to content

Commit a827c62

Browse files
committed
void server returns "no content" header
1 parent 91db3e3 commit a827c62

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

void_server/main.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var (
1212
addr = flag.String("addr", ":8080", "TCP address to listen to")
1313
)
1414

15-
var body = []byte("OK")
15+
var body = []byte("\n")
1616

1717
func main() {
1818
flag.Parse()
@@ -22,14 +22,11 @@ func main() {
2222
log.Fatal(err)
2323
}
2424

25-
if err := fasthttp.Serve(ln, requestHandler); err != nil {
25+
if err := fasthttp.Serve(ln, defaultRequestHandler); err != nil {
2626
log.Fatalf("Error in ListenAndServe: %s", err)
2727
}
2828
}
2929

30-
func requestHandler(ctx *fasthttp.RequestCtx) {
31-
_, err := ctx.Write(body)
32-
if err != nil {
33-
log.Fatal(err)
34-
}
30+
func defaultRequestHandler(ctx *fasthttp.RequestCtx) {
31+
ctx.SetStatusCode(fasthttp.StatusNoContent)
3532
}

0 commit comments

Comments
 (0)