-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
response from local file #36
Comments
It's not supported but looks good. |
I also require this functionality. I need to read response content and alter specific sections of it using regular expressions |
Just a discussion, does this feature related to some API changes? |
Yes, actually I'm going to change API fundamentally. |
I've tested #40, the speed is good, but I cannot find a clue how to response from local file without actually making request out. |
Could you take a look #45? |
Can you provide an example of how to convert the res variable to text for rendering, given the following code:
I want to replace the base with the content of the return to make modifications |
You can receive bodies in proxy and send back full body. let server = proxy
.bind(("127.0.0.1", 3003), move |_client_addr, req| {
let client = client.clone();
async move {
let uri = req.uri().clone();
// You can modify request here
// or You can just return response anyware
let (res, _upgrade) = client.send_request(req).await?;
println!("{} -> {}", uri, res.status());
let (parts, body) = res.into_parts();
let body = body.collect().await?.to_bytes();
println!("{}", String::from_utf8_lossy(&body));
// You can modify response here
Ok::<_, http_mitm_proxy::default_client::Error>(Response::from_parts(
parts,
http_body_util::Full::new(body),
))
}
})
.await
.unwrap(); |
@hatoo |
Solved! |
I have a proxy rule like below:
Want to response from local file
/test/x.json
directly without any actual network request when the uri is https://example.com/x.json.Is it supported and how to do that?
The text was updated successfully, but these errors were encountered: