Open nikolapejic95 opened 4 years ago
Is the onRequest called for your website?
The code on stackoverflow looks strange. I doubt that it is from the example from here. Why do you use Task.Run instead of simply awaiting that call? I think you should not call the GetResponseBody from the onRequest handler, since the request will be sent to the server only after this call...so you won't be able to get the response here.
HI @honfika
thank you for the fast response!
Oh my God... I can't believe I've missed that :|
Putting modifications under onResponse works like a charm, thank you for the help!
By the way, I'm using Task.Run since await gives me "Cannot await void" for some reason. I'm using .NET 4.5
Yeah, because it is a symchronous method, in it unnecessary to wrap it in a task and await it... it just makes your code slower.
help
at the onRequest function of ProxyTestController. you can add if (e.HttpClient.Request.Method == "GET" || e.HttpClient.Request.Method == "POST") { var bodyBytes = await e.GetRequestBody(); e.SetRequestBody(bodyBytes);
var body = e.GetRequestBodyAsString();
//e.SetRequestBodyString(body.Result);
if (body.Result.Contains("username")) {
string _aloc = body.Result.Replace("xxx", "yyy");
e.SetRequestBodyString(_aloc);
}
}
Hi everyone, I'm having a problem with modifying the requests before they reach the browser. I've posted the question on stack overflow, please check it out:
https://stackoverflow.com/questions/63508922/titanium-web-proxy-cant-modify-request-body
The solution might be obvious, but I don't seem to be able to find out how to fix it. Any help would be appreciated.