2 writes to Headers
Microsoft.NET.Sdk.Publish.Tasks (2)
Tasks\Http\HttpClientExtensions.cs (2)
57Headers = 114Headers =
198 references to Headers
aspire (1)
Commands\TelemetryCommandHelpers.cs (1)
96var mediaType = response.Content.Headers.ContentType?.MediaType;
Aspire.Dashboard.Tests (33)
Integration\McpServiceTests.cs (3)
327content.Headers.TryAddWithoutValidation("content-type", "application/json"); 361notificationContent.Headers.TryAddWithoutValidation("content-type", "application/json"); 388content.Headers.TryAddWithoutValidation("content-type", "application/json");
Integration\OtlpHttpJsonTests.cs (6)
418Assert.Equal(OtlpHttpEndpointsBuilder.JsonContentType, responseMessage.Content.Headers.ContentType?.MediaType); 479Assert.Equal(OtlpHttpEndpointsBuilder.JsonContentType, responseMessage.Content.Headers.ContentType?.MediaType); 556Assert.Equal(OtlpHttpEndpointsBuilder.JsonContentType, responseMessage.Content.Headers.ContentType?.MediaType); 606Assert.Equal(OtlpHttpEndpointsBuilder.JsonContentType, responseMessage.Content.Headers.ContentType?.MediaType); 667Assert.Equal(OtlpHttpEndpointsBuilder.JsonContentType, responseMessage.Content.Headers.ContentType?.MediaType); 727Assert.Equal(OtlpHttpEndpointsBuilder.JsonContentType, responseMessage.Content.Headers.ContentType?.MediaType);
Integration\OtlpHttpServiceTests.cs (18)
47content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 56Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single()); 73content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 117content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 141content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 169content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 182Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single()); 207content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 236content.Headers.TryAddWithoutValidation("content-type", contentType); 267content.Headers.TryAddWithoutValidation("content-type", contentType); 275Assert.Equal("application/json", responseMessage.Content.Headers.ContentType?.MediaType); 312content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 338content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 347Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single()); 367content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 376Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single()); 396content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 405Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single());
Integration\ResponseCompressionTests.cs (2)
31Assert.DoesNotContain(response.Content.Headers, h => h.Key == "Content-Encoding"); 53Assert.Contains(response.Content.Headers, h => h.Key == "Content-Encoding" && h.Value.Contains("br"));
Integration\StartupTests.cs (2)
529content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 536Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single());
Integration\TelemetryApiTests.cs (2)
422Assert.Equal("application/x-ndjson", response.Content.Headers.ContentType?.MediaType); 453Assert.Equal("application/x-ndjson", response.Content.Headers.ContentType?.MediaType);
Aspire.Hosting (1)
Dcp\DcpKubernetesClient.cs (1)
131httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/merge-patch+json");
Binding.Http.IntegrationTests (4)
BasicHttpBindingTests.4.0.0.cs (4)
166foreach (var header in oldContent.Headers) 168if (!header.Key.Equals("Content-Length") && message.Content.Headers.Contains(header.Key)) 170message.Content.Headers.Remove(header.Key); 173message.Content.Headers.Add(header.Key, header.Value);
DevTunnels.ApiService (1)
Program.cs (1)
16var contentLength = response.Content.Headers.ContentLength ?? (await response.Content.ReadAsStringAsync()).Length;
dotnet-svcutil-lib (25)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpRequestMessageExtensionMethods.cs (2)
84MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, requestMessage.Headers, requestMessage.Content.Headers); 107headers = headers.Concat(httpRequest.Content.Headers);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpRequestMessageProperty.cs (5)
324long? contentLength = content.Headers.ContentLength; 340(!content.Headers.ContentLength.HasValue || 341content.Headers.ContentLength.Value > 0)) 344foreach (KeyValuePair<string, IEnumerable<string>> header in content.Headers) 346newContent.Headers.AddHeaderWithoutValidation(header);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpResponseMessageExtensionMethods.cs (2)
45HttpRequestMessageExtensionMethods.MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, responseMessage.Headers, responseMessage.Content.Headers); 53headers = headers.Concat(httpResponse.Content.Headers);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpResponseMessageHelper.cs (7)
132var mediaValueContentType = content.Headers.ContentType; 134_contentLength = content.Headers.ContentLength.HasValue ? content.Headers.ContentLength.Value : -1; 175if (!content.Headers.ContentLength.HasValue) 297_contentLength = content.Headers.ContentLength.HasValue ? content.Headers.ContentLength.Value : -1; 341throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(string.Format(SRServiceModel.FramingContentTypeMismatch, _httpRequestMessage.Content.Headers.ContentType.ToString(), _httpRequestMessage.RequestUri)));
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpResponseMessageProperty.cs (5)
348long? contentLength = content.Headers.ContentLength; 364(!content.Headers.ContentLength.HasValue || 365content.Headers.ContentLength.Value > 0)) 368foreach (KeyValuePair<string, IEnumerable<string>> header in content.Headers) 370newContent.Headers.AddHeaderWithoutValidation(header);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\MessageContent.cs (4)
96var actionParams = (from p in Headers.ContentType.Parameters where p.Name == "action" select p).ToArray(); 113new ProtocolException(string.Format(SRServiceModel.HttpContentTypeFormatException, formatException.Message, Headers.ContentType.ToString()), formatException)); 120Headers.ContentType.Parameters.Add(new NameValueHeaderValue("action", action)); 132Headers.ContentType = contentTypeHeaderValue;
Microsoft.Build.Tasks.Core (5)
DownloadFile.cs (5)
198Log.LogErrorFromResources("DownloadFile.Downloading", SourceUrl, destinationFile.FullName, response.Content.Headers.ContentLength); 208Log.LogMessageFromResources(MessageImportance.High, "DownloadFile.Downloading", SourceUrl, destinationFile.FullName, response.Content.Headers.ContentLength); 357&& destinationFile.Length == response.Content.Headers.ContentLength 358&& response.Content.Headers.LastModified.HasValue 359&& destinationFile.LastWriteTimeUtc > response.Content.Headers.LastModified.Value.UtcDateTime;
Microsoft.Deployment.DotNet.Releases (1)
Utils.cs (1)
35DateTime? onlineLastModified = httpResponse.Content.Headers.LastModified?.DateTime;
Microsoft.Extensions.AI.Evaluation.Safety (1)
ContentSafetyService.cs (1)
444httpRequestMessage.Content?.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Microsoft.Extensions.AI.Integration.Tests (5)
VerbatimHttpHandler.cs (2)
58foreach (var header in request.Content.Headers) 60newContent.Headers.TryAddWithoutValidation(header.Key, header.Value);
VerbatimMultiPartHttpHandler.cs (3)
49Assert.NotNull(request.Content.Headers.ContentType); 50Assert.Equal("multipart/form-data", request.Content.Headers.ContentType.MediaType); 61string? boundary = request.Content.Headers.ContentType.Parameters
Microsoft.Extensions.DataIngestion.Tests (2)
Readers\DocumentReaderConformanceTests.cs (2)
85source, mediaType: response.Content.Headers.ContentType?.MediaType!); 183string extension = response.Content.Headers.ContentType?.MediaType switch
Microsoft.Extensions.Http (4)
Logging\LogHelper.cs (4)
81new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Request, request.Headers, request.Content?.Headers, shouldRedactHeaderValue), 96new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Response, response.Headers, response.Content?.Headers, shouldRedactHeaderValue), 120new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Request, request.Headers, request.Content?.Headers, shouldRedactHeaderValue), 135new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Response, response.Headers, response.Content?.Headers, shouldRedactHeaderValue),
Microsoft.Extensions.Http.Diagnostics (6)
Logging\Internal\HttpHeadersReader.cs (2)
51ReadHeaders(request.Content.Headers, _requestHeadersToLog, destination); 69ReadHeaders(response.Content.Headers, _responseHeadersToLog, destination);
Logging\Internal\HttpRequestBodyReader.cs (1)
44var contentType = request.Content.Headers.ContentType;
Logging\Internal\HttpResponseBodyReader.cs (3)
49MediaTypeHeaderValue? contentType = response.Content.Headers.ContentType; 119foreach (KeyValuePair<string, IEnumerable<string>> header in response.Content.Headers) 121_ = newContent.Headers.TryAddWithoutValidation(header.Key, header.Value);
Microsoft.Extensions.Http.Diagnostics.PerformanceTests (2)
NoRemoteCallHandler.cs (1)
44response.Content.Headers.ContentType = new("application/json");
NoRemoteCallNotSeekableHandler.cs (1)
47response.Content.Headers.ContentType = new("application/json");
Microsoft.Extensions.Http.Diagnostics.Tests (14)
Logging\HttpClientLoggerTest.cs (2)
866requestContent.Headers.Add("Content-Type", TextPlain); 877responseContent.Headers.Add("Content-Type", TextPlain);
Logging\HttpHeadersReaderTest.cs (6)
132requestContent.Headers.ContentType = new(MediaTypeNames.Application.Soap); 133requestContent.Headers.ContentLength = 42; 134requestContent.Headers.Add("Content-Header1", "Content.1"); 141responseContent.Headers.ContentType = new(MediaTypeNames.Text.Html); 142responseContent.Headers.ContentLength = 24; 143responseContent.Headers.Add("Content-Header2", "Content.2");
Logging\HttpRequestBodyReaderTest.cs (1)
189httpRequest.Content.Headers.Add("Content-type", "text/plain");
Logging\HttpResponseBodyReaderTest.cs (4)
157httpResponse.Content.Headers.Add("Content-Type", TextPlain); 184httpResponse.Content.Headers.Add("Content-Type", TextPlain); 225httpResponse.Content.Headers.Add("Content-type", TextPlain); 253httpResponse.Content.Headers.Add("Content-type", TextPlain);
Logging\Internal\NoRemoteCallHandler.cs (1)
38response.Content.Headers.ContentType = new("application/json");
Microsoft.ML.PerformanceTests (1)
ImageClassificationBench.cs (1)
164var totalSizeInBytes = headerResponse.Content.Headers.ContentLength;
Microsoft.NET.Build.Containers (8)
Registry\DefaultBlobUploadOperations.cs (2)
78httpContent.Headers.ContentLength = content.Length; 107_logger.LogTrace("Uploading {0} bytes of content at {1}", content.Headers.ContentLength, uploadUri);
Registry\DefaultManifestOperations.cs (1)
44manifestUploadContent.Headers.ContentType = new MediaTypeHeaderValue(mediaType);
Registry\Registry.cs (5)
195return initialManifestResponse.Content.Headers.ContentType?.MediaType switch 200initialManifestResponse.Content.Headers.ContentType.MediaType, 243return initialManifestResponse.Content.Headers.ContentType?.MediaType switch 493content.Headers.ContentLength = bytesRead; 497Debug.Assert(content.Headers.TryAddWithoutValidation("Content-Range", $"{chunkStart}-{chunkStart + bytesRead - 1}"));
Microsoft.NET.Sdk.Publish.Tasks (4)
Kudu\KuduVfsDeploy.cs (2)
63content.Headers.Remove("Content-Type"); 64content.Headers.Add("Content-Type", "application/octet-stream");
Kudu\KuduZipDeploy.cs (2)
54content.Headers.Remove("Content-Type"); 55content.Headers.Add("Content-Type", "application/octet-stream");
Microsoft.TemplateSearch.Common (1)
Providers\NuGetMetadataSearchProvider.cs (1)
241foreach (KeyValuePair<string, IEnumerable<string>> header in response.Content.Headers)
NuGet.Packaging (1)
Signing\Timestamp\Rfc3161TimestampRequestNetstandard21Wrapper.cs (1)
58content.Headers.ContentType = new MediaTypeHeaderValue("application/timestamp-query");
NuGet.Protocol (6)
HttpSource\HttpRequestMessageExtensions.cs (3)
64foreach (var header in _httpContent.Headers) 66Headers.TryAddWithoutValidation(header.Key, header.Value); 77var contentLength = _httpContent.Headers.ContentLength;
HttpSource\HttpRetryHandler.cs (2)
188foreach (var header in response.Content.Headers) 190newContent.Headers.TryAddWithoutValidation(header.Key, header.Value);
Resources\PackageUpdateResource.cs (1)
659packageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream");
Pipelines.Library (1)
DistributedApplicationPipelineExtensions.cs (1)
154content.Headers.ContentType = new MediaTypeHeaderValue("application/zip");
System.Net.Http (39)
System\Net\Http\FormUrlEncodedContent.cs (1)
23Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
System\Net\Http\HttpClient.cs (3)
204c.Headers.ContentLength.GetValueOrDefault(), 218return HttpContent.ReadBufferAsString(buffer, c.Headers); 280c.Headers.ContentLength.GetValueOrDefault(),
System\Net\Http\HttpContent.cs (2)
110return ReadBufferAsString(_bufferedContent, Headers); 621long contentLength = Headers.ContentLength.GetValueOrDefault();
System\Net\Http\HttpRequestMessage.cs (1)
168HeaderUtilities.DumpHeaders(ref sb, _headers, _content?.Headers);
System\Net\Http\HttpResponseMessage.cs (1)
196HeaderUtilities.DumpHeaders(ref sb, _headers, _content?.Headers);
System\Net\Http\MultipartContent.cs (3)
61Headers.ContentType = contentType; 318foreach (KeyValuePair<string, HeaderStringValues> headerPair in content.Headers.NonValidated) 362foreach (KeyValuePair<string, HeaderStringValues> headerPair in content.Headers.NonValidated)
System\Net\Http\MultipartFormDataContent.cs (3)
30content.Headers.ContentDisposition ??= new ContentDispositionHeaderValue(formData); 54if (content.Headers.ContentDisposition == null) 61content.Headers.ContentDisposition = header;
System\Net\Http\SocketsHttpHandler\DecompressionHandler.cs (5)
101if (response.Content.Headers.TryGetValues(KnownHeaders.ContentEncoding.Descriptor, out IEnumerable<string>? contentEncodings)) 152SetHeaders(originalContent.Headers); 153Headers.ContentLength = null; 154Headers.Remove(KnownHeaders.ContentEncoding.Descriptor); 158Headers.TryAddWithoutValidation(KnownHeaders.ContentEncoding.Descriptor, contentEncodings[..^1]);
System\Net\Http\SocketsHttpHandler\Http2Connection.cs (1)
1574headerListSize += WriteHeaderCollection(request, request.Content.Headers, ref headerBuffer);
System\Net\Http\SocketsHttpHandler\Http2Stream.cs (2)
210using var writeStream = new Http2WriteStream(this, _request.Content.Headers.ContentLength.GetValueOrDefault(-1)); 718_response.Content.Headers.TryAddWithoutValidation(descriptor, headerValue);
System\Net\Http\SocketsHttpHandler\Http3RequestStream.cs (5)
260bool useEmptyResponseContent = responseContent.Headers.ContentLength == 0 && sendContentObserved; 482_requestContentLengthRemaining = content.Headers.ContentLength ?? -1; 494long contentLength = content.Headers.ContentLength.GetValueOrDefault(); 741headerListSize += BufferHeaderCollection(request.Content.Headers); 1149_response!.Content!.Headers.TryAddWithoutValidation(descriptor, headerValue);
System\Net\Http\SocketsHttpHandler\HttpConnection.cs (7)
383WriteHeaderCollection(content.Headers); 729(request.Content.Headers.ContentLength == null || request.Content.Headers.ContentLength.GetValueOrDefault() > Expect100ErrorSendThreshold) && 815else if (response.Content.Headers.ContentLength != null) 817long contentLength = response.Content.Headers.ContentLength.GetValueOrDefault(); 950new ContentLengthWriteStream(this, request.Content.Headers.ContentLength.GetValueOrDefault()); 1306headers = response.Content!.Headers;
System\Net\Http\SocketsHttpHandler\SocketsHttpHandler.cs (2)
655request.Content.Headers.ContentLength = null; 657else if (request.Content != null && request.Content.Headers.ContentLength == null)
System\Net\Http\StringContent.cs (3)
68Headers.TryAddWithoutValidation(KnownHeaders.ContentType.Descriptor, knownValue); 73Headers.ContentType = new MediaTypeHeaderValue(mediaType, encoding.WebName); 83Headers.ContentType = mediaType;
System.Net.Http.Json (4)
System\Net\Http\Json\HttpClientJsonExtensions.cs (1)
123if (response.Content.Headers.ContentLength is long contentLength && contentLength > contentLengthLimit)
System\Net\Http\Json\JsonContent.cs (2)
35Headers.ContentType = mediaType; 39Headers.TryAddWithoutValidation("Content-Type", JsonHelpers.DefaultMediaType);
System\Net\Http\Json\JsonHelpers.cs (1)
34if (content.Headers.ContentType?.CharSet is string charset)
System.Net.Http.WinHttpHandler (9)
System\Net\Http\WinHttpHandler.cs (7)
671if (requestContent.Headers.ContentLength.HasValue) 679requestContent.Headers.ContentLength = null; 751if (requestMessage.Content.Headers.ContentLength.HasValue) 753long contentLength = requestMessage.Content.Headers.ContentLength.Value; 754requestMessage.Content.Headers.ContentLength = null; 755requestMessage.Content.Headers.ContentLength = contentLength; 758requestHeadersBuffer.AppendLine(requestMessage.Content.Headers.ToString());
System\Net\Http\WinHttpResponseParser.cs (2)
71state.ExpectedBytesToRead = response.Content.Headers.ContentLength; 283HttpContentHeaders contentHeaders = response.Content.Headers;
System.Net.Requests (5)
System\Net\HttpWebRequest.cs (1)
1227_sendRequestMessage.Content.Headers.TryAddWithoutValidation(headerName, _webHeaderCollection[headerName!]);
System\Net\HttpWebResponse.cs (4)
86return _httpResponseMessage.Content?.Headers.ContentLength ?? -1; 99if (_httpResponseMessage.Content != null && _httpResponseMessage.Content.Headers.TryGetValues("Content-Type", out IEnumerable<string>? values)) 119return GetHeaderValueAsString(_httpResponseMessage.Content.Headers.ContentEncoding); 210foreach (var header in _httpResponseMessage.Content.Headers)
System.ServiceModel.Http (14)
System\ServiceModel\Channels\HttpChannelFactory.cs (1)
1025var contentType = httpRequestMessage.Content.Headers.ContentType;
System\ServiceModel\Channels\HttpResponseMessageExtensionMethods.cs (2)
39MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, responseMessage.Headers, responseMessage.Content.Headers); 47headers = headers.Concat(httpResponse.Content.Headers);
System\ServiceModel\Channels\HttpResponseMessageHelper.cs (7)
135var mediaValueContentType = content.Headers.ContentType; 137_contentLength = content.Headers.ContentLength.HasValue ? content.Headers.ContentLength.Value : -1; 179if (!content.Headers.ContentLength.HasValue) 315_contentLength = content.Headers.ContentLength.HasValue ? content.Headers.ContentLength.Value : -1; 369throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.Format(SR.FramingContentTypeMismatch, _httpRequestMessage.Content.Headers.ContentType.ToString(), _httpRequestMessage.RequestUri)));
System\ServiceModel\Channels\MessageContent.cs (4)
102var actionParams = (from p in Headers.ContentType.Parameters where p.Name == "action" select p).ToArray(); 119new ProtocolException(SR.Format(SR.HttpContentTypeFormatException, formatException.Message, Headers.ContentType.ToString()), formatException)); 126Headers.ContentType.Parameters.Add(new NameValueHeaderValue("action", action)); 138Headers.ContentType = contentTypeHeaderValue;