MCPcopy Index your code
hub / github.com/subtrace/subtrace / ModifyRequest

Method ModifyRequest

cmd/proxy/proxy.go:200–227  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

198}
199
200func (c *Command) ModifyRequest(req *http.Request) error {
201 if c.global.Devtools.HijackPath != "" && req.URL.Path == c.global.Devtools.HijackPath {
202 conn, brw, err := martian.NewContext(req).Session().Hijack()
203 if err != nil {
204 return fmt.Errorf("subtrace: failed to hijack devtools endpoint: %w", err)
205 }
206
207 c.global.Devtools.HandleHijack(req, conn, brw)
208 return nil
209 }
210
211 suffix := req.URL.EscapedPath()
212 if !strings.HasPrefix(suffix, "/") {
213 suffix = "/" + suffix
214 }
215 if req.URL.RawQuery != "" {
216 suffix += "?" + req.URL.RawQuery
217 }
218
219 u, err := url.Parse(fmt.Sprintf("http://0.0.0.0:%d", c.to) + suffix)
220 if err != nil {
221 return fmt.Errorf("parse remote addr: %w", err)
222 }
223
224 req.URL = u
225 req.Header.Del("accept-encoding")
226 return nil
227}
228
229func (c *Command) RoundTrip(req *http.Request) (*http.Response, error) {
230 event := c.global.Config.GetEventTemplate()

Callers

nothing calls this directly

Calls 2

HijackMethod · 0.80
HandleHijackMethod · 0.80

Tested by

no test coverage detected