I'm using Titanium-Web-Proxy to test WebSocket4Net connections through proxies. Titanium is returning the following response to HTTP CONNECT:
HTTP/1.1 200 Connection Established
content-length: 0
WebSocket4Net is processing this in two chunks:
HTTP/1.1 200 Connection Established
and
content-length: 0
After processing the first chunk, prevMatched is 2 because SearchMark matched the \r\n at the end of Connection Established. This logic later:
int responseLength = prevMatched > 0 ? (e.Offset - prevMatched) : (e.Offset + result);
assumes that prevMatched > 0 means that the partial match was in the middle of the closing \r\n\r\n. However, in this case it is not, and the check fails.
This logic seems to be working around the fact that SearchMark does not move result backwards to the start of the match when it is resuming in the middle of a partial match.
I think the line should be this:
int responseLength = (prevMatched > 0 && result == e.Offset) ? (e.Offset - prevMatched) : result;
I'm using Titanium-Web-Proxy to test WebSocket4Net connections through proxies. Titanium is returning the following response to HTTP CONNECT:
WebSocket4Net is processing this in two chunks:
and
After processing the first chunk, prevMatched is 2 because SearchMark matched the \r\n at the end of Connection Established. This logic later:
int responseLength = prevMatched > 0 ? (e.Offset - prevMatched) : (e.Offset + result);assumes that prevMatched > 0 means that the partial match was in the middle of the closing \r\n\r\n. However, in this case it is not, and the check fails.
This logic seems to be working around the fact that SearchMark does not move result backwards to the start of the match when it is resuming in the middle of a partial match.
I think the line should be this:
int responseLength = (prevMatched > 0 && result == e.Offset) ? (e.Offset - prevMatched) : result;