[server] Use responseHeaders.SetRaw for dummy responses

This commit is contained in:
Ciprian Dorin Craciun 2019-08-13 09:10:47 +03:00
parent 97fcd4edd6
commit 306b47fe5d
5 changed files with 8 additions and 6 deletions

View file

@ -70,8 +70,10 @@ func main () () {
func serve (_context *fasthttp.RequestCtx) () { func serve (_context *fasthttp.RequestCtx) () {
_context.Response.Header.SetRaw (serveMeta)
_context.Response.SetBodyRaw (serveData) _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") var serveData = []byte ("hello world!\n")

View file

@ -376,7 +376,7 @@ func (_server *server) ServeError (_context *fasthttp.RequestCtx, _status uint,
func (_server *server) ServeDummy (_context *fasthttp.RequestCtx) () { func (_server *server) ServeDummy (_context *fasthttp.RequestCtx) () {
if true { if false {
_server.ServeStatic (_context, http.StatusOK, DummyData, DummyContentType, DummyContentEncoding, false) _server.ServeStatic (_context, http.StatusOK, DummyData, DummyContentType, DummyContentEncoding, false)
} else { } else {
ServeDummyRaw (_context) ServeDummyRaw (_context)
@ -384,14 +384,13 @@ func (_server *server) ServeDummy (_context *fasthttp.RequestCtx) () {
} }
func ServeDummyRaw (_context *fasthttp.RequestCtx) () { func ServeDummyRaw (_context *fasthttp.RequestCtx) () {
_context.Response.Header.SetRaw (DummyMeta)
_context.Response.SetBodyRaw (DummyData) _context.Response.SetBodyRaw (DummyData)
_context.Response.SetStatusCode (200)
} }
func main () () { func main () () {
Main (main_0) Main (main_0)
} }

View file

@ -15,4 +15,4 @@ require (
replace github.com/colinmarc/cdb => github.com/cipriancraciun/go-cdb-lib v0.0.0-20190809203657-d959ce9cc674 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

View file

@ -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/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 h1:UyoEJxLS9OPdjyinKfCA2aKgIf1NhXyIxneRSMrqZls=
github.com/cipriancraciun/go-cdb-lib v0.0.0-20190809203657-d959ce9cc674/go.mod h1:/M2lSbkwYzIP5OqU4u+aygk4LCVpB7wi60O0Myhs05g= 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-20190813060955-d5d95a7316ea h1:xd5IfIRmGS2Dt6otu9PCjk4UVrZExqvmQOxfjct588c=
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/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

View file

@ -17,6 +17,7 @@ var HeartbeatDataNok = []byte ("NOK\n")
var DummyContentType = MimeTypeText var DummyContentType = MimeTypeText
var DummyContentEncoding = "identity" 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") var DummyData = []byte ("hello world!\n")