/// <summary> /// Gets the HTTP verb to use for a given <see cref="HttpDeliveryMethods"/> enum value. /// </summary> /// <param name="httpMethod">The HTTP method.</param> /// <returns>An HTTP verb, such as GET, POST, PUT, or DELETE.</returns> internal static string GetHttpVerb(HttpDeliveryMethods httpMethod) { if ((httpMethod & HttpDeliveryMethods.HttpVerbMask) == HttpDeliveryMethods.GetRequest) { return("GET"); } else if ((httpMethod & HttpDeliveryMethods.HttpVerbMask) == HttpDeliveryMethods.PostRequest) { return("POST"); } else if ((httpMethod & HttpDeliveryMethods.HttpVerbMask) == HttpDeliveryMethods.PutRequest) { return("PUT"); } else if ((httpMethod & HttpDeliveryMethods.HttpVerbMask) == HttpDeliveryMethods.DeleteRequest) { return("DELETE"); } else if ((httpMethod & HttpDeliveryMethods.HttpVerbMask) == HttpDeliveryMethods.HeadRequest) { return("HEAD"); } else if ((httpMethod & HttpDeliveryMethods.AuthorizationHeaderRequest) != 0) { return("GET"); // if AuthorizationHeaderRequest is specified without an explicit HTTP verb, assume GET. } else { throw ErrorUtilities.ThrowArgumentNamed("httpMethod", MessagingStrings.UnsupportedHttpVerb, httpMethod); } }
/// <summary> /// Gets the <see cref="HttpDeliveryMethods"/> enum value for a given HTTP verb. /// </summary> /// <param name="httpVerb">The HTTP verb.</param> /// <returns>A <see cref="HttpDeliveryMethods"/> enum value that is within the <see cref="HttpDeliveryMethods.HttpVerbMask"/>.</returns> /// <exception cref="ArgumentException">Thrown if the HTTP request is something we can't handle.</exception> internal static HttpDeliveryMethods GetHttpDeliveryMethod(string httpVerb) { if (httpVerb == "GET") { return(HttpDeliveryMethods.GetRequest); } else if (httpVerb == "POST") { return(HttpDeliveryMethods.PostRequest); } else if (httpVerb == "PUT") { return(HttpDeliveryMethods.PutRequest); } else if (httpVerb == "DELETE") { return(HttpDeliveryMethods.DeleteRequest); } else if (httpVerb == "HEAD") { return(HttpDeliveryMethods.HeadRequest); } else { throw ErrorUtilities.ThrowArgumentNamed("httpVerb", MessagingStrings.UnsupportedHttpVerb, httpVerb); } }