Commit 4d1782f7 authored by Honfika's avatar Honfika

fix

parent 20424032
......@@ -73,9 +73,9 @@ namespace Titanium.Web.Proxy.Http
var buf = ArrayPool<byte>.Shared.Rent(str.Length * 4);
var span = new Span<byte>(buf);
encoding.GetBytes(str.AsSpan(), span);
int bytes = encoding.GetBytes(str.AsSpan(), span);
stream.Write(span);
stream.Write(span.Slice(0, bytes));
ArrayPool<byte>.Shared.Return(buf);
#else
var data = encoding.GetBytes(str);
......
......@@ -157,12 +157,7 @@ namespace Titanium.Web.Proxy.Http
{
var headerBuilder = new HeaderBuilder();
headerBuilder.WriteRequestLine(Method, RequestUriString, HttpVersion);
foreach (var header in Headers)
{
headerBuilder.WriteHeader(header);
}
headerBuilder.WriteLine();
headerBuilder.WriteHeaders(Headers);
return HttpHelper.HeaderEncoding.GetString(headerBuilder.GetBytes());
}
}
......
......@@ -37,7 +37,7 @@ namespace Titanium.Web.Proxy.Http
/// <summary>
/// Response Status description.
/// </summary>
public string StatusDescription { get; set; }
public string StatusDescription { get; set; } = string.Empty;
/// <summary>
/// Has response body?
......@@ -122,11 +122,6 @@ namespace Titanium.Web.Proxy.Http
}
}
internal static string CreateResponseLine(Version version, int statusCode, string statusDescription)
{
return $"HTTP/{version.Major}.{version.Minor} {statusCode} {statusDescription}";
}
internal static void ParseResponseLine(string httpStatus, out Version version, out int statusCode,
out string statusDescription)
{
......
......@@ -15,7 +15,7 @@ namespace Titanium.Web.Proxy.Http.Responses
public GenericResponse(HttpStatusCode status)
{
StatusCode = (int)status;
StatusDescription = Get(StatusCode);
StatusDescription = Get(StatusCode) ?? string.Empty;
}
/// <summary>
......@@ -98,6 +98,7 @@ namespace Titanium.Web.Proxy.Http.Responses
case 510: return "Not Extended";
case 511: return "Network Authentication Required";
}
return null;
}
}
......
......@@ -259,6 +259,7 @@ namespace Titanium.Web.Proxy.Http2
response.HttpVersion = HttpVersion.Version20;
int.TryParse(headerListener.Status, out int statusCode);
response.StatusCode = statusCode;
response.StatusDescription = string.Empty;
}
}
catch (Exception ex)
......
......@@ -7,7 +7,7 @@
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>StrongNameKey.snk</AssemblyOriginatorKeyFile>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<LangVersion>7.1</LangVersion>
<LangVersion>8.0</LangVersion>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
......
......@@ -8,7 +8,7 @@
<AssemblyOriginatorKeyFile>StrongNameKey.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<LangVersion>7.1</LangVersion>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
......
......@@ -8,7 +8,7 @@
<AssemblyOriginatorKeyFile>StrongNameKey.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<LangVersion>7.1</LangVersion>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
......
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