From 306b47fe5d655ca038af5b005b2c7ce57c8495d4 Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Tue, 13 Aug 2019 09:10:47 +0300 Subject: [PATCH] [server] Use `responseHeaders.SetRaw` for dummy responses --- sources/cmd/server-dummy.go | 2 ++ sources/cmd/server.go | 5 ++--- sources/go.mod | 2 +- sources/go.sum | 4 ++-- sources/lib/server/favicon.go | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sources/cmd/server-dummy.go b/sources/cmd/server-dummy.go index 7308eb5..4e52afd 100644 --- a/sources/cmd/server-dummy.go +++ b/sources/cmd/server-dummy.go @@ -70,8 +70,10 @@ func main () () { func serve (_context *fasthttp.RequestCtx) () { + _context.Response.Header.SetRaw (serveMeta) _context.Response.SetBodyRaw (serveData) } +var serveMeta = []byte ("HTTP/1.1 200 OK\r\nContent-Length: 13\r\n\r\n") var serveData = []byte ("hello world!\n") diff --git a/sources/cmd/server.go b/sources/cmd/server.go index 1446cc8..7309262 100644 --- a/sources/cmd/server.go +++ b/sources/cmd/server.go @@ -376,7 +376,7 @@ func (_server *server) ServeError (_context *fasthttp.RequestCtx, _status uint, func (_server *server) ServeDummy (_context *fasthttp.RequestCtx) () { - if true { + if false { _server.ServeStatic (_context, http.StatusOK, DummyData, DummyContentType, DummyContentEncoding, false) } else { ServeDummyRaw (_context) @@ -384,14 +384,13 @@ func (_server *server) ServeDummy (_context *fasthttp.RequestCtx) () { } func ServeDummyRaw (_context *fasthttp.RequestCtx) () { + _context.Response.Header.SetRaw (DummyMeta) _context.Response.SetBodyRaw (DummyData) - _context.Response.SetStatusCode (200) } - func main () () { Main (main_0) } diff --git a/sources/go.mod b/sources/go.mod index dce2377..82609ac 100644 --- a/sources/go.mod +++ b/sources/go.mod @@ -15,4 +15,4 @@ require ( replace github.com/colinmarc/cdb => github.com/cipriancraciun/go-cdb-lib v0.0.0-20190809203657-d959ce9cc674 -replace github.com/valyala/fasthttp => github.com/cipriancraciun/go-fasthttp v0.0.0-20190812185442-4ac031052252 +replace github.com/valyala/fasthttp => github.com/cipriancraciun/go-fasthttp v0.0.0-20190813060955-d5d95a7316ea diff --git a/sources/go.sum b/sources/go.sum index ed0facc..bdabac6 100644 --- a/sources/go.sum +++ b/sources/go.sum @@ -2,8 +2,8 @@ github.com/Pallinder/go-randomdata v1.2.0 h1:DZ41wBchNRb/0GfsePLiSwb0PHZmT67XY00 github.com/Pallinder/go-randomdata v1.2.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y= github.com/cipriancraciun/go-cdb-lib v0.0.0-20190809203657-d959ce9cc674 h1:UyoEJxLS9OPdjyinKfCA2aKgIf1NhXyIxneRSMrqZls= github.com/cipriancraciun/go-cdb-lib v0.0.0-20190809203657-d959ce9cc674/go.mod h1:/M2lSbkwYzIP5OqU4u+aygk4LCVpB7wi60O0Myhs05g= -github.com/cipriancraciun/go-fasthttp v0.0.0-20190812185442-4ac031052252 h1:RtCq6tOQYYsM/A8xBj4WNw0y2+X1iwT3VSZ3DMasZRc= -github.com/cipriancraciun/go-fasthttp v0.0.0-20190812185442-4ac031052252/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s= +github.com/cipriancraciun/go-fasthttp v0.0.0-20190813060955-d5d95a7316ea h1:xd5IfIRmGS2Dt6otu9PCjk4UVrZExqvmQOxfjct588c= +github.com/cipriancraciun/go-fasthttp v0.0.0-20190813060955-d5d95a7316ea/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/sources/lib/server/favicon.go b/sources/lib/server/favicon.go index 0dd2640..a2ab00a 100644 --- a/sources/lib/server/favicon.go +++ b/sources/lib/server/favicon.go @@ -17,6 +17,7 @@ var HeartbeatDataNok = []byte ("NOK\n") var DummyContentType = MimeTypeText var DummyContentEncoding = "identity" +var DummyMeta = []byte ("HTTP/1.1 200 OK\r\nContent-Length: 13\r\n\r\n") var DummyData = []byte ("hello world!\n")