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

Commit 167bb2f

Browse files
committed
Fix version parse
1 parent 1849d31 commit 167bb2f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Titanium.Web.Proxy/RequestHandler.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private static async void HandleClient(ExplicitProxyEndPoint endPoint, TcpClient
5555
Version version = new Version(1, 1);
5656
if (httpCmdSplit.Length == 3)
5757
{
58-
string httpVersion = httpCmdSplit[1].Trim();
58+
string httpVersion = httpCmdSplit[2].Trim();
5959

6060
if (httpVersion == "http/1.0")
6161
{
@@ -204,24 +204,24 @@ private static async Task HandleHttpSessionRequest(TcpClient client, string http
204204
var httpCmdSplit = httpCmd.Split(Constants.SpaceSplit, 3);
205205

206206
var httpMethod = httpCmdSplit[0];
207-
var httpVersion = httpCmdSplit[2].ToLower().Trim();
208207

209-
Version version;
210-
if (httpVersion == "http/1.1")
208+
Version version = new Version(1, 1);
209+
if (httpCmdSplit.Length == 3)
211210
{
212-
version = new Version(1, 1);
213-
}
214-
else
215-
{
216-
version = new Version(1, 0);
211+
var httpVersion = httpCmdSplit[2].ToLower().Trim();
212+
213+
if (httpVersion == "http/1.0")
214+
{
215+
version = new Version(1, 0);
216+
}
217217
}
218218

219219
args.WebSession.Request.RequestHeaders = new List<HttpHeader>();
220220

221221
string tmpLine;
222222
while (!string.IsNullOrEmpty(tmpLine = await clientStreamReader.ReadLineAsync().ConfigureAwait(false)))
223223
{
224-
var header = tmpLine.Split(new char[] { ':' }, 2);
224+
var header = tmpLine.Split(Constants.ColonSplit, 2);
225225
args.WebSession.Request.RequestHeaders.Add(new HttpHeader(header[0], header[1]));
226226
}
227227

0 commit comments

Comments
 (0)