Exemplo n.º 1
0
        private HttpRequestMessage CreateRequestWithOptionalBody(IDictionary <string, string> sendPairs, IHypertextControl hypertextControl)
        {
            logger?.LogDebug("Creating HTTP request.");

            HttpRequestMessage httpRequest;

            if (hypertextControl.SupportsRequestBody())
            {
                httpRequest = new HttpRequestMessage(hypertextControl.DetermineHttpMethod(), hypertextControl.HRef)
                {
                    Content = this.PrepareHttpContent(sendPairs, hypertextControl)
                };
            }
            else
            {
                httpRequest = new HttpRequestMessage(hypertextControl.DetermineHttpMethod(), this.PrepareUri(sendPairs, hypertextControl));
            }

            return(httpRequest);
        }
Exemplo n.º 2
0
        public static bool SupportsRequestBody(this IHypertextControl hypertextControl)
        {
            var method = hypertextControl.DetermineHttpMethod();

            if (method == HttpMethod.Post)
            {
                return(true);
            }
            else if (method == HttpMethod.Put)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }