[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.dummy {
|
||||||
if !_server.dummyEmpty {
|
if !_server.dummyEmpty {
|
||||||
_responseHeaders := _response.Header ()
|
_responseHeaders := NewHttpResponseWriterHeadersBuffer (http.StatusOK)
|
||||||
_responseHeaders["Content-Type"] = []string { DummyContentType }
|
_responseHeaders.IncludeString ("Content-Type", DummyContentType)
|
||||||
_responseHeaders["Content-Encoding"] = []string { DummyContentEncoding }
|
_responseHeaders.IncludeString ("Content-Encoding", DummyContentEncoding)
|
||||||
_responseHeaders["Cache-Control"] = []string { "no-store, max-age=0" }
|
_responseHeaders.IncludeString ("Cache-Control", "no-store, max-age=0")
|
||||||
_responseHeaders["Date"] = nil
|
_responseHeaders.WriteTo (_response)
|
||||||
_response.WriteHeader (http.StatusOK)
|
|
||||||
_response.Write (DummyData)
|
_response.Write (DummyData)
|
||||||
}
|
}
|
||||||
if _server.dummyDelay != 0 {
|
if _server.dummyDelay != 0 {
|
||||||
|
@ -523,7 +522,7 @@ func (_server *server) ServeHTTP (_response http.ResponseWriter, _request *http.
|
||||||
case "Connection", "Content-Length", "Date" :
|
case "Connection", "Content-Length", "Date" :
|
||||||
// NOP
|
// NOP
|
||||||
default :
|
default :
|
||||||
_responseHeaders.Include (_key, _value)
|
_responseHeaders.IncludeBytes (_key, _value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -812,7 +811,7 @@ func main_0 () (error) {
|
||||||
|
|
||||||
debug.SetGCPercent (50)
|
debug.SetGCPercent (50)
|
||||||
debug.SetMaxThreads (int (128 * (_threads / 64 + 1)))
|
debug.SetMaxThreads (int (128 * (_threads / 64 + 1)))
|
||||||
debug.SetMaxStack (16 * 1024)
|
debug.SetMaxStack (32 * 1024)
|
||||||
|
|
||||||
|
|
||||||
_httpReduceMemory := false
|
_httpReduceMemory := false
|
||||||
|
|
|
@ -11,6 +11,9 @@ import "sync/atomic"
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
|
|
||||||
|
import . "github.com/volution/kawipiko/lib/common"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type HttpResponseWriterHeadersBuffer struct {
|
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 {
|
if _buffer.headersCount == 128 {
|
||||||
panic ("[ca806ede]")
|
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) () {
|
func (_buffer *HttpResponseWriterHeadersBuffer) WriteToGenericResponse (_response http.ResponseWriter) () {
|
||||||
|
|
Loading…
Reference in a new issue