mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-02 14:00:27 +08:00
手动发送数据(Send()方法)时也可以使用HTTP Header策略等
This commit is contained in:
@@ -843,6 +843,14 @@ func (this *HTTPWriter) WriteHeader(statusCode int) {
|
|||||||
|
|
||||||
// Send 直接发送内容,并终止请求
|
// Send 直接发送内容,并终止请求
|
||||||
func (this *HTTPWriter) Send(status int, body string) {
|
func (this *HTTPWriter) Send(status int, body string) {
|
||||||
|
this.req.processResponseHeaders(this.Header(), status)
|
||||||
|
|
||||||
|
// content-length
|
||||||
|
_, hasContentLength := this.Header()["Content-Length"]
|
||||||
|
if !hasContentLength {
|
||||||
|
this.Header()["Content-Length"] = []string{types.String(len(body))}
|
||||||
|
}
|
||||||
|
|
||||||
this.WriteHeader(status)
|
this.WriteHeader(status)
|
||||||
_, _ = this.WriteString(body)
|
_, _ = this.WriteString(body)
|
||||||
this.isFinished = true
|
this.isFinished = true
|
||||||
@@ -888,6 +896,7 @@ func (this *HTTPWriter) SendResp(resp *http.Response) (int64, error) {
|
|||||||
for k, v := range resp.Header {
|
for k, v := range resp.Header {
|
||||||
this.SetHeader(k, v)
|
this.SetHeader(k, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.WriteHeader(resp.StatusCode)
|
this.WriteHeader(resp.StatusCode)
|
||||||
var bufPool = this.req.bytePool(resp.ContentLength)
|
var bufPool = this.req.bytePool(resp.ContentLength)
|
||||||
var buf = bufPool.Get()
|
var buf = bufPool.Get()
|
||||||
|
|||||||
Reference in New Issue
Block a user