GithubHelp home page GithubHelp logo

Comments (7)

kr avatar kr commented on August 17, 2024 1

You might want to look at httputil.DumpRequestOut and httputil.DumpResponse — I bet those will help!

from mitm.

kr avatar kr commented on August 17, 2024 1

For plaintext http, I'd suggest bypassing this package altogether. There should be no need for mitm in that case.

from mitm.

santhoshTpixler avatar santhoshTpixler commented on August 17, 2024

It helped me well. But for response capturing, I have only http.ResponseWriter

from mitm.

kr avatar kr commented on August 17, 2024

Ah, true. You might be able to use httptest.ResponseRecorder to make a second ResponseWriter, and provide that to the upstream handler to capture the response. Then you could use its Result method to dump the result.

You'll probably also have to write some code to copy the result data from the ResponseRecorder to the original ResponseWriter that goes to the client.

Note that this will mean collecting the entire response in memory. If it's a big response, that'll take a lot of memory and the client will have to wait longer for the response. If that's not okay, then you could instead make your own wrapper type for the ResponseWriter that streams the response, bit by bit, to both the client and to the file. That would mean writing significantly more code.

Finally, you should use httputil.DumpRequest instead of DumpRequestOut. Sorry for the wrong advice before.

from mitm.

santhoshTpixler avatar santhoshTpixler commented on August 17, 2024

@kr Got it. Thank you for your valuable support.

from mitm.

santhoshTpixler avatar santhoshTpixler commented on August 17, 2024

@kr HTTPS requests are proxied as expected. But HTTP requests are getting timed out. Any idea on how to fix it?

from mitm.

brydavis avatar brydavis commented on August 17, 2024

Use a multi-writer to write bytes to multiple readers.

Standard output used here, but you could add / replace it with a file, etc.

m := io.MultiWriter(
	w.ResponseWriter,
	os.Stdout,
)

m.Write([]byte("some data..."))

from mitm.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.