Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions src/libraries/Common/src/System/Net/WebHeaderEncoding.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
Link="Common\System\Net\LazyAsyncResult.cs" />
<Compile Include="$(CommonPath)System\Net\UriScheme.cs"
Link="Common\System\Net\UriScheme.cs" />
<Compile Include="$(CommonPath)System\Net\WebHeaderEncoding.cs"
Link="Common\System\Net\WebHeaderEncoding.cs" />
<Compile Include="$(CommonPath)System\Net\WebSockets\WebSocketValidate.cs"
Link="Common\System\Net\WebSockets\WebSocketValidate.cs" />
<Compile Include="System\Net\Windows\CookieExtensions.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ internal void SendHeaders(bool closing, MemoryStream ms, bool isWebSocketHandsha
StreamWriter writer = new StreamWriter(ms, encoding, 256);
writer.Write("HTTP/1.1 {0} ", _statusCode); // "1.1" matches Windows implementation, which ignores the response version
writer.Flush();
byte[] statusDescriptionBytes = WebHeaderEncoding.GetBytes(StatusDescription);
byte[] statusDescriptionBytes = Encoding.Latin1.GetBytes(StatusDescription);
ms.Write(statusDescriptionBytes, 0, statusDescriptionBytes.Length);
writer.Write("\r\n");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ public HttpListenerContext EndGetContext(IAsyncResult asyncResult)
{
bytes = Convert.FromBase64String(inBlob);

inBlob = WebHeaderEncoding.GetString(bytes, 0, bytes.Length);
inBlob = Encoding.Latin1.GetString(bytes);
index = inBlob.IndexOf(':');

if (index != -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,10 @@ internal unsafe uint SendHeaders(Interop.HttpApi.HTTP_DATA_CHUNK* pDataChunk,
if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, "Calling Interop.HttpApi.HttpSendHttpResponse flags:" + flags);
if (StatusDescription.Length > 0)
{
byte[] statusDescriptionBytes = new byte[WebHeaderEncoding.GetByteCount(StatusDescription)];
byte[] statusDescriptionBytes = Encoding.Latin1.GetBytes(StatusDescription);
fixed (byte* pStatusDescription = &statusDescriptionBytes[0])
{
_nativeResponse.ReasonLength = (ushort)statusDescriptionBytes.Length;
WebHeaderEncoding.GetBytes(StatusDescription, 0, statusDescriptionBytes.Length, statusDescriptionBytes, 0);
_nativeResponse.pReason = (sbyte*)pStatusDescription;
fixed (Interop.HttpApi.HTTP_RESPONSE* pResponse = &_nativeResponse)
{
Expand Down Expand Up @@ -525,18 +524,16 @@ internal void ComputeCoreHeaders()
for (int headerValueIndex = 0; headerValueIndex < headerValues.Length; headerValueIndex++)
{
//Add Name
bytes = new byte[WebHeaderEncoding.GetByteCount(headerName)];
bytes = Encoding.Latin1.GetBytes(headerName);
unknownHeaders[headers.UnknownHeaderCount].NameLength = (ushort)bytes.Length;
WebHeaderEncoding.GetBytes(headerName, 0, bytes.Length, bytes, 0);
gcHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
pinnedHeaders.Add(gcHandle);
unknownHeaders[headers.UnknownHeaderCount].pName = (sbyte*)gcHandle.AddrOfPinnedObject();

//Add Value
headerValue = headerValues[headerValueIndex];
bytes = new byte[WebHeaderEncoding.GetByteCount(headerValue)];
bytes = Encoding.Latin1.GetBytes(headerValue);
unknownHeaders[headers.UnknownHeaderCount].RawValueLength = (ushort)bytes.Length;
WebHeaderEncoding.GetBytes(headerValue, 0, bytes.Length, bytes, 0);
gcHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
pinnedHeaders.Add(gcHandle);
unknownHeaders[headers.UnknownHeaderCount].pRawValue = (sbyte*)gcHandle.AddrOfPinnedObject();
Expand All @@ -549,9 +546,8 @@ internal void ComputeCoreHeaders()
if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"HttpResponseHeader[{lookup}]:{((HttpResponseHeader)lookup)} headerValue:{headerValue}");
if (headerValue != null)
{
bytes = new byte[WebHeaderEncoding.GetByteCount(headerValue)];
bytes = Encoding.Latin1.GetBytes(headerValue);
pKnownHeaders[lookup].RawValueLength = (ushort)bytes.Length;
WebHeaderEncoding.GetBytes(headerValue, 0, bytes.Length, bytes, 0);
gcHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
pinnedHeaders.Add(gcHandle);
pKnownHeaders[lookup].pRawValue = (sbyte*)gcHandle.AddrOfPinnedObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public async Task StatusDescription_GetWithCustomStatusCode_ReturnsExpected(int

[Theory]
[InlineData("", "", 118)]
[InlineData("A !#\t1\u1234", "A !#\t14", 125)] //
[InlineData("A !#\t1\u1234", "A !#\t1?", 125)] //
[InlineData("StatusDescription", "StatusDescription", 135)]
[InlineData(" StatusDescription ", " StatusDescription ", 139)]
public async Task StatusDescription_SetCustom_Success(string statusDescription, string expectedStatusDescription, int expectedNumberOfBytes)
Expand Down
Loading