mirror of
https://github.com/eolinker/apinto
synced 2025-10-05 16:57:03 +08:00
系统变量新增proxy相关字段
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package http_context
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
http_service "github.com/eolinker/eosc/eocontext/http-context"
|
||||
)
|
||||
|
||||
@@ -22,12 +26,30 @@ type requestAgent struct {
|
||||
hostAgent *UrlAgent
|
||||
remoteIP string
|
||||
remotePort int
|
||||
originHeader *fasthttp.ResponseHeader
|
||||
headers http.Header
|
||||
}
|
||||
|
||||
func (a *requestAgent) ResponseBody() string {
|
||||
return a.responseBody
|
||||
}
|
||||
|
||||
func (a *requestAgent) ResponseHeaders() http.Header {
|
||||
if a.headers != nil {
|
||||
return a.headers
|
||||
}
|
||||
if a.originHeader == nil {
|
||||
return make(http.Header)
|
||||
}
|
||||
headers := make(http.Header)
|
||||
a.originHeader.VisitAll(func(key, value []byte) {
|
||||
bytes.SplitN(value, []byte(":"), 2)
|
||||
headers[string(key)] = []string{string(value)}
|
||||
})
|
||||
a.headers = headers
|
||||
return a.headers
|
||||
}
|
||||
|
||||
func (a *requestAgent) ProxyTime() time.Time {
|
||||
return a.beginTime
|
||||
}
|
||||
@@ -63,8 +85,8 @@ func (a *requestAgent) setRemotePort(port int) {
|
||||
a.remotePort = port
|
||||
}
|
||||
|
||||
func newRequestAgent(IRequest http_service.IRequest, host string, scheme string, beginTime, endTime time.Time) *requestAgent {
|
||||
return &requestAgent{IRequest: IRequest, host: host, scheme: scheme, beginTime: beginTime, endTime: endTime}
|
||||
func newRequestAgent(IRequest http_service.IRequest, host string, scheme string, header *fasthttp.ResponseHeader, beginTime, endTime time.Time) *requestAgent {
|
||||
return &requestAgent{IRequest: IRequest, host: host, scheme: scheme, beginTime: beginTime, endTime: endTime, originHeader: header}
|
||||
}
|
||||
|
||||
func (a *requestAgent) ResponseTime() int64 {
|
||||
|
Reference in New Issue
Block a user