Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

Commit

Permalink
Expect 100 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
justcoding121 committed Apr 19, 2016
1 parent 0c997fd commit 9c08874
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Titanium.Web.Proxy/Network/HttpWebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,27 @@ public void SendRequest()
stream.Write(requestBytes, 0, requestBytes.Length);
stream.Flush();

if (ProxyServer.Enable100ContinueBehaviour)
if (this.Request.ExpectContinue)
{
var httpResult = ProxyClient.ServerStreamReader.ReadLine().Split(new char[] { ' ' }, 3);
var responseStatusCode = httpResult[1].Trim();
var responseStatusDescription = httpResult[2].Trim();

//find if server is willing for expect continue
if (responseStatusCode.Equals("100")
&& responseStatusDescription.ToLower().Equals("continue"))
{
this.Request.Is100Continue = true;
ProxyClient.ServerStreamReader.ReadLine();
}
else if (responseStatusCode.Equals("417")
&& responseStatusDescription.ToLower().Equals("expectation failed"))
{
this.Request.ExpectationFailed = true;
ProxyClient.ServerStreamReader.ReadLine();
}
}
}

public void ReceiveResponse()
Expand All @@ -342,6 +363,7 @@ public void ReceiveResponse()
this.Response.ResponseStatusCode = httpResult[1].Trim();
this.Response.ResponseStatusDescription = httpResult[2].Trim();

//For HTTP 1.1 comptibility server may send expect-continue even if not asked for it in request
if (this.Response.ResponseStatusCode.Equals("100")
&& this.Response.ResponseStatusDescription.ToLower().Equals("continue"))
{
Expand All @@ -351,6 +373,8 @@ public void ReceiveResponse()
ReceiveResponse();
return;
}
else if (this.Response.ResponseStatusCode.Equals("417")
&& this.Response.ResponseStatusDescription.ToLower().Equals("expectation failed"))
{
this.Response.ExpectationFailed = true;
this.Response.ResponseStatusCode = null;
Expand Down

0 comments on commit 9c08874

Please sign in to comment.