Comments (7)
You might want to look at httputil.DumpRequestOut and httputil.DumpResponse — I bet those will help!
from mitm.
For plaintext http, I'd suggest bypassing this package altogether. There should be no need for mitm in that case.
from mitm.
It helped me well. But for response capturing, I have only http.ResponseWriter
from mitm.
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.
@kr Got it. Thank you for your valuable support.
from mitm.
@kr HTTPS requests are proxied as expected. But HTTP requests are getting timed out. Any idea on how to fix it?
from mitm.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mitm.