()
| 22 | ) |
| 23 | |
| 24 | func (this *HTTPRequest) doFastcgi() (shouldStop bool) { |
| 25 | fastcgiList := []*serverconfigs.HTTPFastcgiConfig{} |
| 26 | for _, fastcgi := range this.web.FastcgiList { |
| 27 | if !fastcgi.IsOn { |
| 28 | continue |
| 29 | } |
| 30 | fastcgiList = append(fastcgiList, fastcgi) |
| 31 | } |
| 32 | if len(fastcgiList) == 0 { |
| 33 | return false |
| 34 | } |
| 35 | shouldStop = true |
| 36 | fastcgi := fastcgiList[rands.Int(0, len(fastcgiList)-1)] |
| 37 | |
| 38 | env := fastcgi.FilterParams() |
| 39 | if !env.Has("DOCUMENT_ROOT") { |
| 40 | env["DOCUMENT_ROOT"] = "" |
| 41 | } |
| 42 | |
| 43 | if !env.Has("REMOTE_ADDR") { |
| 44 | env["REMOTE_ADDR"] = this.requestRemoteAddr(true) |
| 45 | } |
| 46 | if !env.Has("QUERY_STRING") { |
| 47 | u, err := url.ParseRequestURI(this.uri) |
| 48 | if err == nil { |
| 49 | env["QUERY_STRING"] = u.RawQuery |
| 50 | } else { |
| 51 | env["QUERY_STRING"] = this.RawReq.URL.RawQuery |
| 52 | } |
| 53 | } |
| 54 | if !env.Has("SERVER_NAME") { |
| 55 | env["SERVER_NAME"] = this.ReqHost |
| 56 | } |
| 57 | if !env.Has("REQUEST_URI") { |
| 58 | env["REQUEST_URI"] = this.uri |
| 59 | } |
| 60 | if !env.Has("HOST") { |
| 61 | env["HOST"] = this.ReqHost |
| 62 | } |
| 63 | |
| 64 | if len(this.ServerAddr) > 0 { |
| 65 | if !env.Has("SERVER_ADDR") { |
| 66 | env["SERVER_ADDR"] = this.ServerAddr |
| 67 | } |
| 68 | if !env.Has("SERVER_PORT") { |
| 69 | _, port, err := net.SplitHostPort(this.ServerAddr) |
| 70 | if err == nil { |
| 71 | env["SERVER_PORT"] = port |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // 设置为持久化连接 |
| 77 | var requestConn = this.RawReq.Context().Value(HTTPConnContextKey) |
| 78 | if requestConn == nil { |
| 79 | return |
| 80 | } |
| 81 | requestClientConn, ok := requestConn.(ClientConnInterface) |
no test coverage detected