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

Method ModifyRequest

cmd/run/socket/proxy.go:1519–1537  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

1517}
1518
1519func (h *hijacker) ModifyRequest(req *http.Request) error {
1520 if req.URL.Path == h.proxy.global.Devtools.HijackPath {
1521 // We need to serve the devtools bundle by hijacking the client-side
1522 // connection. As a result, this proxy will no longer be used for regular
1523 // HTTP requests (i.e. non-devtools paths). Some programs such as Python's
1524 // SimpleHTTPServer are single-threaded, which means they will be blocked
1525 // until the last open connection finishes. As a result, we must first
1526 // close the server-side connection before starting the Martian hijack.
1527 h.srv.Close()
1528
1529 conn, brw, err := martian.NewContext(req).Session().Hijack()
1530 if err != nil {
1531 return fmt.Errorf("subtrace: failed to hijack devtools endpoint: %w", err)
1532 }
1533 h.proxy.global.Devtools.HandleHijack(req, conn, brw)
1534 }
1535
1536 return nil
1537}
1538
1539func (h *hijacker) RoundTrip(req *http.Request) (*http.Response, error) {
1540 event := h.proxy.global.Config.GetEventTemplate()

Callers

nothing calls this directly

Calls 3

HijackMethod · 0.80
HandleHijackMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected