(ctx *context, req *http.Request)
| 1206 | } |
| 1207 | |
| 1208 | func (p *Proxy) getRoundTripper(ctx *context, req *http.Request) (http.RoundTripper, error) { |
| 1209 | switch req.URL.Scheme { |
| 1210 | case "fastcgi": |
| 1211 | f := "index.php" |
| 1212 | if sf, ok := ctx.StateBag()["fastCgiFilename"]; ok { |
| 1213 | f = sf.(string) |
| 1214 | } else if len(req.URL.Path) > 1 && req.URL.Path != "/" { |
| 1215 | f = req.URL.Path[1:] |
| 1216 | } |
| 1217 | rt, err := fastcgi.NewRoundTripper(p.log, req.URL.Host, f) |
| 1218 | if err != nil { |
| 1219 | return nil, err |
| 1220 | } |
| 1221 | |
| 1222 | // FastCgi expects the Host to be in form host:port |
| 1223 | // It will then be split and added as 2 separate params to the backend process |
| 1224 | if _, _, err := net.SplitHostPort(req.Host); err != nil { |
| 1225 | req.Host = req.Host + ":" + req.URL.Port() |
| 1226 | } |
| 1227 | |
| 1228 | // RemoteAddr is needed to pass to the backend process as param |
| 1229 | req.RemoteAddr = ctx.request.RemoteAddr |
| 1230 | |
| 1231 | return rt, nil |
| 1232 | default: |
| 1233 | return p.roundTripper, nil |
| 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | func (p *Proxy) rejectBackend(ctx *context, req *http.Request) (*http.Response, bool) { |
| 1238 | limit, ok := ctx.StateBag()[filters.BackendRatelimit].(*ratelimitfilters.BackendRatelimit) |
no test coverage detected