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

Commit 5cecf4f

Browse files
author
Paul S
committed
Fix environment specific header termination on Unix.
1 parent 0478f21 commit 5cecf4f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Titanium.Web.Proxy/Http/HttpWebClient.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Titanium.Web.Proxy.Http
1616
/// </summary>
1717
public class HttpWebClient
1818
{
19+
private const string CRLF = "\r\n";
1920

2021
internal HttpWebClient(Request request = null, Response response = null)
2122
{
@@ -103,26 +104,29 @@ await writer.WriteLineAsync(Request.CreateRequestLine(Request.Method,
103104
Request.HttpVersion), cancellationToken);
104105

105106
var headerBuilder = new StringBuilder();
107+
106108
// Send Authentication to Upstream proxy if needed
107109
if (!isTransparent && upstreamProxy != null
108110
&& ServerConnection.IsHttps == false
109111
&& !string.IsNullOrEmpty(upstreamProxy.UserName)
110112
&& upstreamProxy.Password != null)
111113
{
112-
headerBuilder.AppendLine(HttpHeader.ProxyConnectionKeepAlive.ToString());
113-
headerBuilder.AppendLine(HttpHeader.GetProxyAuthorizationHeader(upstreamProxy.UserName, upstreamProxy.Password).ToString());
114+
headerBuilder.AppendFormat("{0}{1}", HttpHeader.ProxyConnectionKeepAlive, CRLF);
115+
headerBuilder.AppendFormat("{0}{1}",
116+
HttpHeader.GetProxyAuthorizationHeader(upstreamProxy.UserName, upstreamProxy.Password));
114117
}
115118

116119
// write request headers
117120
foreach (var header in Request.Headers)
118121
{
119122
if (isTransparent || header.Name != KnownHeaders.ProxyAuthorization)
120123
{
121-
headerBuilder.AppendLine(header.ToString());
124+
headerBuilder.AppendFormat("{0}{1}", header, CRLF);
122125
}
123126
}
124127

125-
headerBuilder.AppendLine();
128+
headerBuilder.Append(CRLF);
129+
126130
await writer.WriteAsync(headerBuilder.ToString(), cancellationToken);
127131

128132
if (enable100ContinueBehaviour)

0 commit comments

Comments
 (0)