Ejemplo n.º 1
0
        public HttpPostRequest(string address, IHttpHeadersCollection headers, IPostContent postContent, TimeSpan?timeout = null, bool allowRedirects = true)
            : base(address, headers, timeout, allowRedirects)
        {
            Contract.Requires <ArgumentNullException>(postContent != null);

            _postContent = postContent;
        }
Ejemplo n.º 2
0
        private HttpContent GetHttpContent(IPostContent postContent)
        {
            if (postContent.GetType() == typeof(StringPostContent))
            {
                var stringPostContent = (StringPostContent)postContent;
                return(new StringContent(stringPostContent.Data, stringPostContent.Encoding, stringPostContent.MediaType));
            }
            if (postContent.GetType() == typeof(FormUrlEncodedPostContent))
            {
                return(new FormUrlEncodedContent(((FormUrlEncodedPostContent)postContent).Data));
            }

            throw new NotSupportedException(String.Format("Unknown post content type: {0}", postContent.GetType()));
        }
Ejemplo n.º 3
0
 public void On(IPostContent postContent) => PostContent.Execute(postContent);