GetResponse() public method

응답 객체를 반환한다.
WebResponse는 사용한 후 꼭 Close를 호출해야 한다.
public GetResponse ( string method = "Get" ) : WebResponse
method string 참고
return System.Net.WebResponse
Esempio n. 1
0
        /// <summary>
        /// 지정된 Web 주소로부터 Http Get을 이용하여 정보를 다운 받는다.
        /// </summary>
        /// <param name="url">서버 주소</param>
        /// <param name="timeout">제한 시간</param>
        /// <param name="userId">인증을 위한 사용자 Id</param>
        /// <param name="password">인증을 위한 비밀번호</param>
        /// <returns>응답 개체 (<c>WebResponse</c> 개체)</returns>
        public static WebResponse GetResponse(string url, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null,
                                              string password = null) {
            if(IsDebugEnabled)
                log.Debug("Get HttpResponse... url=[{0}], timeout=[{1}], userId=[{2}], password=[{3}]", url, timeout, userId, password);

            var httpClient = new HttpClient(url, timeout, userId, password);
            return httpClient.GetResponse(WebRequestMethods.Http.Get);
        }
Esempio n. 2
0
        /// <summary>
        /// 지정된 Web 주소로부터 Http Get을 이용하여 정보를 다운 받는다.
        /// </summary>
        /// <param name="url">서버 주소</param>
        /// <param name="timeout">제한 시간</param>
        /// <param name="userId">인증을 위한 사용자 Id</param>
        /// <param name="password">인증을 위한 비밀번호</param>
        /// <returns>응답 개체 (<c>WebResponse</c> 개체)</returns>
        public static WebResponse GetResponse(string url, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null,
                                              string password         = null)
        {
            if (IsDebugEnabled)
            {
                log.Debug("Get HttpResponse... url=[{0}], timeout=[{1}], userId=[{2}], password=[{3}]", url, timeout, userId, password);
            }

            var httpClient = new HttpClient(url, timeout, userId, password);

            return(httpClient.GetResponse(WebRequestMethods.Http.Get));
        }
Esempio n. 3
0
        /// <summary>
        /// 가장 일반적으로 사용할 함수, 서버에 HTTP로 접속하여 Response를 얻는다.
        /// </summary>
        /// <param name="method">전송 방법 (<see cref="WebRequestMethods.Http"/>참조)</param>
        /// <param name="url">서버 주소</param>
        /// <param name="timeout">제한 시간</param>
        /// <param name="userId">UserId</param>
        /// <param name="password">Password</param>
        /// <returns>결과 <c>WebResponse</c> 인스턴스 개체</returns>
        /// <remarks>WebResponse는 사용한 후 꼭 Close를 호출해야 한다.</remarks>
        public static WebResponse GetResponse(string method,
                                              string url,
                                              int timeout     = HttpConsts.HTTP_DEFAULT_TIMEOUT,
                                              string userId   = null,
                                              string password = null)
        {
            method.ShouldNotBeWhiteSpace("method");
            url.ShouldNotBeWhiteSpace("url");

            if (IsDebugEnabled)
            {
                log.Debug("Get HttpResponse... method=[{0}], url=[{1}], timeout=[{2}], userId=[{3}], password=[{4}]", method, url,
                          timeout, userId, password);
            }

            var httpClient = new HttpClient(url, timeout, userId, password);

            return(httpClient.GetResponse(method));
        }
Esempio n. 4
0
        /// <summary>
        /// 가장 일반적으로 사용할 함수, 서버에 HTTP로 접속하여 Response를 얻는다.
        /// </summary>
        /// <param name="method">전송 방법 (<see cref="WebRequestMethods.Http"/>참조)</param>
        /// <param name="url">서버 주소</param>
        /// <param name="timeout">제한 시간</param>
        /// <param name="userId">UserId</param>
        /// <param name="password">Password</param>
        /// <returns>결과 <c>WebResponse</c> 인스턴스 개체</returns>
        /// <remarks>WebResponse는 사용한 후 꼭 Close를 호출해야 한다.</remarks>
        public static WebResponse GetResponse(string method,
                                              string url,
                                              int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT,
                                              string userId = null,
                                              string password = null) {
            method.ShouldNotBeWhiteSpace("method");
            url.ShouldNotBeWhiteSpace("url");

            if(IsDebugEnabled)
                log.Debug("Get HttpResponse... method=[{0}], url=[{1}], timeout=[{2}], userId=[{3}], password=[{4}]", method, url,
                          timeout, userId, password);

            var httpClient = new HttpClient(url, timeout, userId, password);
            return httpClient.GetResponse(method);
        }