ProxyHTTP further depends on ingress rules to establish a connection with the origin service. This may be a simple roundtrip or a tcp/websocket dial depending on ingres rule setup.
( w connection.ResponseWriter, tr *tracing.TracedHTTPRequest, isWebsocket bool, )
| 78 | // ProxyHTTP further depends on ingress rules to establish a connection with the origin service. This may be |
| 79 | // a simple roundtrip or a tcp/websocket dial depending on ingres rule setup. |
| 80 | func (p *Proxy) ProxyHTTP( |
| 81 | w connection.ResponseWriter, |
| 82 | tr *tracing.TracedHTTPRequest, |
| 83 | isWebsocket bool, |
| 84 | ) error { |
| 85 | incrementRequests() |
| 86 | defer decrementConcurrentRequests() |
| 87 | |
| 88 | req := tr.Request |
| 89 | p.appendTagHeaders(req) |
| 90 | |
| 91 | _, ruleSpan := tr.Tracer().Start(req.Context(), "ingress_match", |
| 92 | trace.WithAttributes(attribute.String("req-host", req.Host))) |
| 93 | rule, ruleNum := p.ingressRules.FindMatchingRule(req.Host, req.URL.Path) |
| 94 | ruleSpan.SetAttributes(attribute.Int("rule-num", ruleNum)) |
| 95 | ruleSpan.End() |
| 96 | logger := newHTTPLogger(p.log, tr.ConnIndex, req, ruleNum, rule.Service.String()) |
| 97 | logHTTPRequest(&logger, req) |
| 98 | if err, applied := p.applyIngressMiddleware(rule, req, w); err != nil { |
| 99 | if applied { |
| 100 | logRequestError(&logger, err) |
| 101 | return nil |
| 102 | } |
| 103 | return err |
| 104 | } |
| 105 | |
| 106 | switch originProxy := rule.Service.(type) { |
| 107 | case ingress.HTTPOriginProxy: |
| 108 | if err := p.proxyHTTPRequest( |
| 109 | w, |
| 110 | tr, |
| 111 | originProxy, |
| 112 | isWebsocket, |
| 113 | rule.Config.DisableChunkedEncoding, |
| 114 | &logger, |
| 115 | ); err != nil { |
| 116 | logRequestError(&logger, err) |
| 117 | return err |
| 118 | } |
| 119 | return nil |
| 120 | case ingress.StreamBasedOriginProxy: |
| 121 | dest, err := getDestFromRule(rule, req) |
| 122 | if err != nil { |
| 123 | return err |
| 124 | } |
| 125 | flusher, ok := w.(http.Flusher) |
| 126 | if !ok { |
| 127 | return fmt.Errorf("response writer is not a flusher") |
| 128 | } |
| 129 | rws := connection.NewHTTPResponseReadWriterAcker(w, flusher, req) |
| 130 | logger := logger.With().Str(logFieldDestAddr, dest).Logger() |
| 131 | if err := p.proxyStream(tr.ToTracedContext(), rws, dest, originProxy, &logger); err != nil { |
| 132 | logRequestError(&logger, err) |
| 133 | return err |
| 134 | } |
| 135 | return nil |
| 136 | case ingress.HTTPLocalProxy: |
| 137 | p.proxyLocalRequest(originProxy, w, req, isWebsocket) |
nothing calls this directly
no test coverage detected