Ejemplo n.º 1
0
        internal HttpRequestMessage CreateRequestMessage(TfsRestRequest request)
        {
            UriBuilder url = new UriBuilder(Configuration.Url);

            url.Path  = UrlHelpers.JoinPath(Configuration.Url.AbsolutePath, GetRequestPath(request));
            url.Query = GetRequestQuery(request);

            HttpRequestMessage message = new HttpRequestMessage(request.Method, url.Uri);

            message.Headers.UserAgent.ParseAdd(
                Configuration.UserAgent ?? DefaultUserAgent);

            foreach (KeyValuePair <string, object> header in request.Headers)
            {
                message.Headers.Add(header.Key, header.Value.ToString());
            }

            string body = request.GetBody();

            if (body != null)
            {
                message.Content = new StringContent(body, Encoding.UTF8, "application/json");
            }

            return(message);
        }
Ejemplo n.º 2
0
 public static void UrlHelpers_CanJoinPaths(string expected, string one, string two)
 {
     Assert.Equal(expected, UrlHelpers.JoinPath(one, two));
 }