예제 #1
0
        public void GetWebRequest()
        {
            HttpRequest    request        = HttpRequestTest.SetContent();
            HttpWebRequest httpWebRequest = HttpResponse.GetWebRequest(request);

            Assert.IsType <HttpWebRequest>(httpWebRequest);
            Assert.Equal("application/octet-stream", httpWebRequest.ContentType);
        }
예제 #2
0
        public void GetWebRequest()
        {
            HttpRequest    request        = HttpRequestTest.SetContent();
            HttpWebRequest httpWebRequest = HttpResponse.GetWebRequest(request);

            Assert.IsType <HttpWebRequest>(httpWebRequest);
            Assert.Equal("application/octet-stream", httpWebRequest.ContentType);

            // 删除 Accept 和 Date 请求头
            request.Headers.Add("Accept", "accept");
            request.Headers.Add("Date", "Thu, 24 Jan 2019 05:16:46 GMT");

            // 覆盖POST方式
            request.Method = MethodType.POST;
            httpWebRequest = HttpResponse.GetWebRequest(request);
            Assert.IsType <HttpWebRequest>(httpWebRequest);
            Assert.Equal("application/octet-stream", httpWebRequest.ContentType);
        }