/// <summary> /// Get the value of a request HTTP header. /// </summary> /// /// <returns> /// The value of the specified HTTP header in the request. /// </returns> /// /// <param name="headerName"> /// The name of an HTTP header. /// </param> public string GetRequestHeaderValue(string headerName) { StringValues values = Request.Headers[headerName]; // Return the value of the first entry. return(values.GetEnumerator().Current); }
private bool SetCurrent(string name, StringValues value, KnownHeaderType knownHeaderType) { _knownHeaderType = knownHeaderType; if (value.Count == 1) { Current = new KeyValuePair <string, string>(name, value.ToString()); _hasMultipleValues = false; return(true); } else { _stringValuesEnumerator = value.GetEnumerator(); _hasMultipleValues = true; return(MoveNextOnStringEnumerator(name)); } }
public void Enumerator(StringValues stringValues, string[] expected) { var e = stringValues.GetEnumerator(); Assert.Null(e.Current); for (int i = 0; i < expected.Length; i++) { Assert.True(e.MoveNext()); Assert.Equal(expected[i], e.Current); } Assert.False(e.MoveNext()); Assert.False(e.MoveNext()); Assert.False(e.MoveNext()); var e1 = ((IEnumerable<string>)stringValues).GetEnumerator(); Assert.Null(e1.Current); for (int i = 0; i < expected.Length; i++) { Assert.True(e1.MoveNext()); Assert.Equal(expected[i], e1.Current); } Assert.False(e1.MoveNext()); Assert.False(e1.MoveNext()); Assert.False(e1.MoveNext()); var e2 = ((IEnumerable)stringValues).GetEnumerator(); Assert.Null(e2.Current); for (int i = 0; i < expected.Length; i++) { Assert.True(e2.MoveNext()); Assert.Equal(expected[i], e2.Current); } Assert.False(e2.MoveNext()); Assert.False(e2.MoveNext()); Assert.False(e2.MoveNext()); }
public void DefaultNullOrEmpty_Enumerator(StringValues stringValues) { var e = stringValues.GetEnumerator(); Assert.Null(e.Current); Assert.False(e.MoveNext()); Assert.Null(e.Current); Assert.False(e.MoveNext()); Assert.False(e.MoveNext()); Assert.False(e.MoveNext()); var e1 = ((IEnumerable<string>)stringValues).GetEnumerator(); Assert.Null(e1.Current); Assert.False(e1.MoveNext()); Assert.Null(e1.Current); Assert.False(e1.MoveNext()); Assert.False(e1.MoveNext()); Assert.False(e1.MoveNext()); var e2 = ((IEnumerable)stringValues).GetEnumerator(); Assert.Null(e2.Current); Assert.False(e2.MoveNext()); Assert.Null(e2.Current); Assert.False(e2.MoveNext()); Assert.False(e2.MoveNext()); Assert.False(e2.MoveNext()); }