Open lightfiretw opened 5 years ago
I can't reproduce this issue.
I've added the following code to the BefureRequest handler:
if (e.HttpClient.Request.RequestUri.ToString().Contains("websocket.org"))
{
e.HttpClient.Request.RequestUri =
new Uri("http://www.httpvshttps.com/?socket=" + e.HttpClient.Request.RequestUri.AbsoluteUri);
e.HttpClient.Request.Host = new Uri("http://www.httpvshttps.com").Host;
}
When opening https://www.websocket.org/echo.html Wiresharks shows:
As expected. (With HTTPS it seems to be the same)
Could you please create a small test project to reproduce the problem?
I've found a related issue, that the HeaderText proeprty (and because that the ToString(), too) shows incorrect request URL, but it is not sent to the server.
By the way: as a workaround for the HeaderText and Request.ToString issue you can set the OriginalUrl ptoperty, too (path only):
e.HttpClient.Request.OriginalUrl = "/?socket=" + e.HttpClient.Request.RequestUri.AbsoluteUri;
Do you have an upstream proxy? I've reproduced the issue in the following configuration:
client => TWP => Fiddler => server
Do you have an upstream proxy? I've reproduced the issue in the following configuration:
Yes, I do. I'm using Burp suite to check if calls are correctly sent. So my flow is like Client=>Burp=>Server. Also noticed something interesting, when using HTTPS for socket upgrade and redirecting the HOST changes(changes to https://mywebsite.com/), but trying with HTTP nothing get changed(https://echo.websocket.org/?encoding=text), it's like it bypassed the proxy.
Could you please try the latest package?
Sure, unfortunately it is still the same. HTTPS the request host is changed but not the request path, HTTP it just ignores the modification for the request and connects to the original request.
I noticed for HTTPS that the httpCmd in RequestHandler.cs handleHttpSessionRequest is set before invokeBeforeRequest(args) is called, causing handleWebSocketUpgrade to connect to unmodified path. Not sure if I'm correct of not though.
Currently I am just straight up setting handleWebSocketUpgrade to suit my needs.
Please try the latest package again.
unfortunately it is still the same.
When trying to change the request URI for socket requests, the requests URI doesn't change.
Code
When testing on https://www.websocket.org/echo.html The first request which is
https://echo.websocket.org/?encoding=text
, should be redirected tohttps://mywebsite.com/?socket=https://echo.websocket.org/?encoding=text
But it turns intohttps://mywebsite.com/?encoding=text
instead.