private void TestSetRequestHeader(Action <DataServiceClientFormat> configureFormat, Action <DataServiceClientFormat, HeaderCollection> setRequestHeader, string expectedHeaderToSet, string initialHeaderValue, string expectedValueAfterSet) { var headers = new HeaderCollection(); configureFormat(this.v3TestSubject); headers.SetHeader(expectedHeaderToSet, initialHeaderValue); // Verify header has the expected initial value. This ensures that SetHeader above actually what we expect, and didn't use a default value or ignore the set request. headers.GetHeader(expectedHeaderToSet).Should().Be(initialHeaderValue); // Try to set header to new value and verify setRequestHeader(this.v3TestSubject, headers); headers.GetHeader(expectedHeaderToSet).Should().Be(expectedValueAfterSet); if (expectedHeaderToSet == "Content-Type") { if (expectedValueAfterSet == TestConstants.MimeApplicationJsonODataMinimalMetadata) { headers.GetHeader("OData-Version").Should().Be("4.0"); } else { headers.GetHeader("OData-Version").Should().BeNull(); } } if (expectedHeaderToSet == "Accept") { headers.GetHeader("Accept-Charset").Should().Be("UTF-8"); } }
public void SetRequestVersionShouldSetCorrectValue() { var headers = new HeaderCollection(); headers.SetRequestVersion(new Version(4, 0, 0, 1), new Version(5, 0, 0, 1)); headers.GetHeader("OData-Version").Should().Be("4.0"); headers.GetHeader("OData-MaxVersion").Should().Be("5.0"); }
public void SetRequestVersionShouldSetCorrectValueWhenHeaderCollectionContainsODataVersionLessThan40() { var headers = new HeaderCollection(); headers.SetHeader("OData-Version", "3.0.0"); headers.SetRequestVersion(new Version(4, 0, 0, 1), new Version(5, 0, 0, 1)); headers.GetHeader("OData-Version").Should().Be("4.0"); headers.GetHeader("OData-MaxVersion").Should().Be("5.0"); }
public void HeaderDictionaryLookupsShouldBeCaseInsensitive() { var dictionary = new HeaderCollection(new WebHeaderCollection { { "CONTENT-TYPE", "something" } }); dictionary.GetHeader("Content-Type").Should().Be("something"); dictionary.GetHeader("content-type").Should().Be("something"); }
public void HeaderDictionaryLookupsShouldBeCaseInsensitive() { WebHeaderCollection webHeaderCollection = new WebHeaderCollection(); webHeaderCollection["CONTENT-TYPE"] = "something"; var dictionary = new HeaderCollection(webHeaderCollection); dictionary.GetHeader("Content-Type").Should().Be("something"); dictionary.GetHeader("content-type").Should().Be("something"); }
public void SetUseAgentShouldSetCorrectValue() { var headers = new HeaderCollection(); headers.SetUserAgent(); headers.HeaderNames.Count().Should().Be(1); headers.GetHeader("User-Agent").Should().Be("Microsoft ADO.NET Data Services"); }
public void SetUseAgentShouldSetCorrectValue() { var headers = new HeaderCollection(); headers.SetUserAgent(); headers.HeaderNames.Count().Should().Be(1); Version assemblyVersion = typeof(HeaderCollection).GetAssembly().GetName().Version; headers.GetHeader("User-Agent").Should().Be(string.Format(CultureInfo.InvariantCulture, "Microsoft.OData.Client/{0}.{1}.{2}", assemblyVersion.Major, assemblyVersion.Minor, assemblyVersion.Build)); }
public MessageHeader GetProperty(XName name) { return(_properties.GetHeader(name)); }
/// <summary> /// Sets the value of the Accept header for a batch request /// Will set it to 'multipart/mixed' for a multipart batch request /// Will set it to 'application/json' for a json batch request /// </summary> /// <param name="headers">The headers to modify.</param> internal void SetRequestAcceptHeaderForBatch(HeaderCollection headers) { bool useJsonBatch = headers.GetHeader(XmlConstants.HttpContentType).Equals(MimeApplicationJson, StringComparison.Ordinal); this.SetAcceptHeaderAndCharset(headers, useJsonBatch ? MimeApplicationJson : MimeMultiPartMixed); }