Commit 5cecf4f1 authored by Paul S's avatar Paul S

Fix environment specific header termination on Unix.

parent 0478f21e
...@@ -16,6 +16,7 @@ namespace Titanium.Web.Proxy.Http ...@@ -16,6 +16,7 @@ namespace Titanium.Web.Proxy.Http
/// </summary> /// </summary>
public class HttpWebClient public class HttpWebClient
{ {
private const string CRLF = "\r\n";
internal HttpWebClient(Request request = null, Response response = null) internal HttpWebClient(Request request = null, Response response = null)
{ {
...@@ -103,14 +104,16 @@ namespace Titanium.Web.Proxy.Http ...@@ -103,14 +104,16 @@ namespace Titanium.Web.Proxy.Http
Request.HttpVersion), cancellationToken); Request.HttpVersion), cancellationToken);
var headerBuilder = new StringBuilder(); var headerBuilder = new StringBuilder();
// Send Authentication to Upstream proxy if needed // Send Authentication to Upstream proxy if needed
if (!isTransparent && upstreamProxy != null if (!isTransparent && upstreamProxy != null
&& ServerConnection.IsHttps == false && ServerConnection.IsHttps == false
&& !string.IsNullOrEmpty(upstreamProxy.UserName) && !string.IsNullOrEmpty(upstreamProxy.UserName)
&& upstreamProxy.Password != null) && upstreamProxy.Password != null)
{ {
headerBuilder.AppendLine(HttpHeader.ProxyConnectionKeepAlive.ToString()); headerBuilder.AppendFormat("{0}{1}", HttpHeader.ProxyConnectionKeepAlive, CRLF);
headerBuilder.AppendLine(HttpHeader.GetProxyAuthorizationHeader(upstreamProxy.UserName, upstreamProxy.Password).ToString()); headerBuilder.AppendFormat("{0}{1}",
HttpHeader.GetProxyAuthorizationHeader(upstreamProxy.UserName, upstreamProxy.Password));
} }
// write request headers // write request headers
...@@ -118,11 +121,12 @@ namespace Titanium.Web.Proxy.Http ...@@ -118,11 +121,12 @@ namespace Titanium.Web.Proxy.Http
{ {
if (isTransparent || header.Name != KnownHeaders.ProxyAuthorization) if (isTransparent || header.Name != KnownHeaders.ProxyAuthorization)
{ {
headerBuilder.AppendLine(header.ToString()); headerBuilder.AppendFormat("{0}{1}", header, CRLF);
} }
} }
headerBuilder.AppendLine(); headerBuilder.Append(CRLF);
await writer.WriteAsync(headerBuilder.ToString(), cancellationToken); await writer.WriteAsync(headerBuilder.ToString(), cancellationToken);
if (enable100ContinueBehaviour) if (enable100ContinueBehaviour)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment