[server] Use "magic" also for Go HTTP handler.
This commit is contained in:
parent
4941dc0b9a
commit
5609528a18
2 changed files with 16 additions and 9 deletions
|
@ -483,12 +483,11 @@ func (_server *server) ServeHTTP (_response http.ResponseWriter, _request *http.
|
|||
|
||||
if _server.dummy {
|
||||
if !_server.dummyEmpty {
|
||||
_responseHeaders := _response.Header ()
|
||||
_responseHeaders["Content-Type"] = []string { DummyContentType }
|
||||
_responseHeaders["Content-Encoding"] = []string { DummyContentEncoding }
|
||||
_responseHeaders["Cache-Control"] = []string { "no-store, max-age=0" }
|
||||
_responseHeaders["Date"] = nil
|
||||
_response.WriteHeader (http.StatusOK)
|
||||
_responseHeaders := NewHttpResponseWriterHeadersBuffer (http.StatusOK)
|
||||
_responseHeaders.IncludeString ("Content-Type", DummyContentType)
|
||||
_responseHeaders.IncludeString ("Content-Encoding", DummyContentEncoding)
|
||||
_responseHeaders.IncludeString ("Cache-Control", "no-store, max-age=0")
|
||||
_responseHeaders.WriteTo (_response)
|
||||
_response.Write (DummyData)
|
||||
}
|
||||
if _server.dummyDelay != 0 {
|
||||
|
@ -523,7 +522,7 @@ func (_server *server) ServeHTTP (_response http.ResponseWriter, _request *http.
|
|||
case "Connection", "Content-Length", "Date" :
|
||||
// NOP
|
||||
default :
|
||||
_responseHeaders.Include (_key, _value)
|
||||
_responseHeaders.IncludeBytes (_key, _value)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -812,7 +811,7 @@ func main_0 () (error) {
|
|||
|
||||
debug.SetGCPercent (50)
|
||||
debug.SetMaxThreads (int (128 * (_threads / 64 + 1)))
|
||||
debug.SetMaxStack (16 * 1024)
|
||||
debug.SetMaxStack (32 * 1024)
|
||||
|
||||
|
||||
_httpReduceMemory := false
|
||||
|
|
|
@ -11,6 +11,9 @@ import "sync/atomic"
|
|||
import "unsafe"
|
||||
|
||||
|
||||
import . "github.com/volution/kawipiko/lib/common"
|
||||
|
||||
|
||||
|
||||
|
||||
type HttpResponseWriterHeadersBuffer struct {
|
||||
|
@ -29,7 +32,7 @@ func NewHttpResponseWriterHeadersBuffer (_status int) (HttpResponseWriterHeaders
|
|||
}
|
||||
|
||||
|
||||
func (_buffer *HttpResponseWriterHeadersBuffer) Include (_name []byte, _value []byte) () {
|
||||
func (_buffer *HttpResponseWriterHeadersBuffer) IncludeBytes (_name []byte, _value []byte) () {
|
||||
|
||||
if _buffer.headersCount == 128 {
|
||||
panic ("[ca806ede]")
|
||||
|
@ -40,6 +43,11 @@ func (_buffer *HttpResponseWriterHeadersBuffer) Include (_name []byte, _value []
|
|||
}
|
||||
|
||||
|
||||
func (_buffer *HttpResponseWriterHeadersBuffer) IncludeString (_name string, _value string) () {
|
||||
_buffer.IncludeBytes (StringToBytes (_name), StringToBytes (_value))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func (_buffer *HttpResponseWriterHeadersBuffer) WriteToGenericResponse (_response http.ResponseWriter) () {
|
||||
|
|
Loading…
Reference in a new issue