Skip to content
This repository was archived by the owner on Jul 28, 2020. It is now read-only.
This repository was archived by the owner on Jul 28, 2020. It is now read-only.

HttpConnectProxy.ProcessReceive fails when the second to last fragment ends in \r\n #92

Description

@EricGriffith

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;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions