/// <summary> /// Performs request processing just prior to execution but after the IWebRequest has called. /// </summary> private HttpRequestMessage PreProcessRequest(ref string relativeUrl, ref HttpMethod method, IList <NameValuePair <string> > additionalHeaders) { //see if we've ever attempted a request - if not we're going to do some first time things. if (m_FirstRequest) { m_UseCompatibilityMethods = GetUseCompatiblilityMethodsOverride(m_HostName); m_UseHttpVersion10 = GetUseHttpVersion10Override(m_HostName); m_FirstRequest = false; } //get rid of any leading slashes relativeUrl = (relativeUrl.StartsWith("/") ? relativeUrl.Substring(1) : relativeUrl); var request = new HttpRequestMessage(method, relativeUrl); //put in any additional headers we got. By doing them first, if they conflict with one of our headers //the conflict will be resolved in favor of the base implementation, forcing the dev to deal with their error first. if (additionalHeaders != null) { foreach (NameValuePair <string> additionalHeader in additionalHeaders) { request.Headers.Add(additionalHeader.Name, additionalHeader.Value); } } //see if we need to override the method. I'm just sick and tired of !@%@ IIS blocking PUT and DELETE. if (m_UseCompatibilityMethods) { if (method == HttpMethod.Put || method == HttpMethod.Delete) { request.Headers.Add(HeaderRequestMethod, method.Method); //and override the method back to post, which will work. method = HttpMethod.Post; request.Method = method; } } request.Version = (m_UseHttpVersion10) ? new Version(1, 0) : new Version(1, 1); //add our request timestamp so everyone agrees. request.Headers.Add(HeaderRequestTimestamp, DateTimeOffset.UtcNow.ToString("o")); //and if we have a protocol version the caller is using specify that so the server knows. if (AppProtocolVersion != null) { request.Headers.Add(HeaderRequestAppProtocolVersion, AppProtocolVersion.ToString()); } //Extension our authentication headers if there is an authentication object if (m_AuthenticationProvider != null) { m_AuthenticationProvider.PreProcessRequest(this, m_Connection, request, relativeUrl, m_RequestSupportsAuthentication); } return(request); }
public void String() { var signer = new PrivateKey(); AppProtocolVersion claim = AppProtocolVersion.Sign(signer, 123); Assert.Equal("123", claim.ToString()); AppProtocolVersion claimWithExtra = AppProtocolVersion.Sign(signer, 456, (Bencodex.Types.Text) "extra"); Assert.Equal("456 (Bencodex.Types.Text \"extra\")", claimWithExtra.ToString()); }