C# Class NSoft.NFramework.Networks.HttpTool

HTTP Protocal을 이용한 통신을 수행하기 위한 Utility Class
显示文件 Open project: debop/NFramework Class Usage Examples

Public Methods

Method Description
GetResponse ( string url, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string password = null ) : WebResponse

지정된 Web 주소로부터 Http Get을 이용하여 정보를 다운 받는다.

GetResponse ( string method, string url, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string password = null ) : WebResponse

가장 일반적으로 사용할 함수, 서버에 HTTP로 접속하여 Response를 얻는다.

WebResponse는 사용한 후 꼭 Close를 호출해야 한다.

GetString ( string url, Encoding enc = null, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string password = null ) : string

주어진 URL에 HTTP GET을 수행한다.

PostString ( string url, string payload, Encoding enc = null, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string password = null ) : string

지정된 Web 주소로부터 Http Post을 이용하여 정보를 전달하고, 결과 정보를 얻는다.

SimpleDownloadData ( string address ) : byte[]

웹으로부터 Data를 다운로드 받는다.

SimpleDownloadFile ( string address, string localFullFileName ) : bool

주어진 주소에서 Web을 통해 파일을 다운로드 받는다.

SimpleUploadFile ( string address, string filename, string method = WebRequestMethods.Http.Post ) : byte[]

지정된 주소로 파일을 전송합니다.

Method Details

GetResponse() public static method

지정된 Web 주소로부터 Http Get을 이용하여 정보를 다운 받는다.
public static GetResponse ( string url, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string password = null ) : WebResponse
url string 서버 주소
timeout int 제한 시간
userId string 인증을 위한 사용자 Id
password string 인증을 위한 비밀번호
return System.Net.WebResponse

GetResponse() public static method

가장 일반적으로 사용할 함수, 서버에 HTTP로 접속하여 Response를 얻는다.
WebResponse는 사용한 후 꼭 Close를 호출해야 한다.
public static GetResponse ( string method, string url, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string password = null ) : WebResponse
method string 전송 방법 (참조)
url string 서버 주소
timeout int 제한 시간
userId string UserId
password string Password
return System.Net.WebResponse

GetString() public static method

주어진 URL에 HTTP GET을 수행한다.
public static GetString ( string url, Encoding enc = null, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string password = null ) : string
url string Server URL
enc System.Text.Encoding Encoding Type
timeout int Connection Timeout (milliseconds)
userId string UserId for Authentication
password string Password for Authentication
return string

PostString() public static method

지정된 Web 주소로부터 Http Post을 이용하여 정보를 전달하고, 결과 정보를 얻는다.
public static PostString ( string url, string payload, Encoding enc = null, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string password = null ) : string
url string 서버 주소
payload string POST 될 데이타 (형식 : PARAM1=VALUE1&PARAM2=VALUE2&PARAM3=VALUE3)
enc System.Text.Encoding 인코딩 방식
timeout int 제한 시간
userId string 인증을 위한 사용자 Id
password string 인증을 위한 비밀번호
return string

SimpleDownloadData() public static method

웹으로부터 Data를 다운로드 받는다.
public static SimpleDownloadData ( string address ) : byte[]
address string 주소
return byte[]

SimpleDownloadFile() public static method

주어진 주소에서 Web을 통해 파일을 다운로드 받는다.
address 주소 잘못 등
public static SimpleDownloadFile ( string address, string localFullFileName ) : bool
address string Web 주소
localFullFileName string 다운 받아 저자할 로칼 파일 전체 경로
return bool

SimpleUploadFile() public static method

지정된 주소로 파일을 전송합니다.
public static SimpleUploadFile ( string address, string filename, string method = WebRequestMethods.Http.Post ) : byte[]
address string 전송할 URL 주소
filename string 전송활 파일 경로
method string 전송 방법 (GET, POST, PUT...)
return byte[]