C# 클래스 NSoft.NFramework.Networks.HttpClient

Http 통신을 수행하는 Client Class
파일 보기 프로젝트 열기: debop/NFramework 1 사용 예제들

공개 메소드들

메소드 설명
DownloadData ( ) : byte[]

해당주소에서 Data를 받습니다.

DownloadFile ( string address, string filename ) : bool

지정한 주소의 내용을 받아서 파일로 저장한다.

Get ( ) : string

URL정보를 기초로 HTTP GET 을 수행한다.

GetResponse ( string method = "Get" ) : WebResponse

응답 객체를 반환한다.

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

Head ( ) : WebHeaderCollection

응답 Header 내용을 반환한다.

HttpClient ( ) : System

Initialize a new instance of HttpClient.

HttpClient ( Uri baseUri ) : System

Initialize a new instance of HttpClient with baseUri.

HttpClient ( Uri baseUri, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string passwd = null ) : System

Initialize a new instance of HttpClient with baseUri, timeout, user id and password

HttpClient ( string baseUriString ) : System

Initialize a new instance of HttpClient with uri string.

HttpClient ( string baseUriString, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string passwd = null ) : System

Initialize a new instance of HttpClient with uri, timeout, user id and password

Post ( NameValueCollection inputs, Encoding enc = null ) : string

지정된 서버에 DATA를 POST 방식으로 전송한다.

Post ( string payload, Encoding enc = null ) : string

주어진 URL를 기초로 Http Post 를 수행한다. ASP.NET 서버인 경우 web.config의 Request/Response Encoding 정보를 잘 보고 해야 한다.

ResponseToArray ( WebResponse response ) : byte[]

Response 정보를 byte array로 변환한다.

길이가 아주 길고, 실제 크기를 알 수 없을 때 Response 개체의 stream을 처리하는 로직이 있음.

UploadFile ( string filename, string method = "POST" ) : byte[]

Client의 지정된 파일을 서버로 전송한다.

비공개 메소드들

메소드 설명
BuildRequest ( ) : HttpWebRequest

요청 객체를 생성한다.

DisposeRequest ( ) : void

내부 Request 개체를 해제한다.

GetCredentials ( ) : ICredentials
GetUri ( Uri relativeUri ) : Uri
GetUri ( string relativePath ) : Uri

기본 Uri와 script path를 가지고 완전한 Uri를 만든다.

OnChanged ( ) : void
PrepareRequestHeaders ( WebRequest request ) : void

Http 메소드를 실행하기 위해 Http 요청 객체(HttpWebRequest)의 헤더 부분을 조정한다.

메소드 상세

DownloadData() 공개 메소드

해당주소에서 Data를 받습니다.
public DownloadData ( ) : byte[]
리턴 byte[]

DownloadFile() 공개 메소드

지정한 주소의 내용을 받아서 파일로 저장한다.
public DownloadFile ( string address, string filename ) : bool
address string 서버 주소
filename string 로칼 파일 경로
리턴 bool

Get() 공개 메소드

URL정보를 기초로 HTTP GET 을 수행한다.
public Get ( ) : string
리턴 string

GetResponse() 공개 메소드

응답 객체를 반환한다.
WebResponse는 사용한 후 꼭 Close를 호출해야 한다.
public GetResponse ( string method = "Get" ) : WebResponse
method string 참고
리턴 System.Net.WebResponse

Head() 공개 메소드

응답 Header 내용을 반환한다.
public Head ( ) : WebHeaderCollection
리턴 System.Net.WebHeaderCollection

HttpClient() 공개 메소드

Initialize a new instance of HttpClient.
public HttpClient ( ) : System
리턴 System

HttpClient() 공개 메소드

Initialize a new instance of HttpClient with baseUri.
public HttpClient ( Uri baseUri ) : System
baseUri System.Uri 서버주소
리턴 System

HttpClient() 공개 메소드

Initialize a new instance of HttpClient with baseUri, timeout, user id and password
public HttpClient ( Uri baseUri, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string passwd = null ) : System
baseUri System.Uri 서버주소
timeout int 통신 timeout (msec 단위)
userId string 사용자 Id
passwd string 비밀번호
리턴 System

HttpClient() 공개 메소드

Initialize a new instance of HttpClient with uri string.
public HttpClient ( string baseUriString ) : System
baseUriString string uri string
리턴 System

HttpClient() 공개 메소드

Initialize a new instance of HttpClient with uri, timeout, user id and password
public HttpClient ( string baseUriString, int timeout = HttpConsts.HTTP_DEFAULT_TIMEOUT, string userId = null, string passwd = null ) : System
baseUriString string uri string
timeout int time for http communication.
userId string user id
passwd string password
리턴 System

Post() 공개 메소드

지정된 서버에 DATA를 POST 방식으로 전송한다.
public Post ( NameValueCollection inputs, Encoding enc = null ) : string
inputs System.Collections.Specialized.NameValueCollection 전송 데이타
enc System.Text.Encoding 인코딩 방식
리턴 string

Post() 공개 메소드

주어진 URL를 기초로 Http Post 를 수행한다. ASP.NET 서버인 경우 web.config의 Request/Response Encoding 정보를 잘 보고 해야 한다.
public Post ( string payload, Encoding enc = null ) : string
payload string 전송할 DATA (ex PARAM1=VALUE1&PARAM2=VALUE2)
enc System.Text.Encoding 전송할 DATA의 Encoding 방식
리턴 string

ResponseToArray() 공개 정적인 메소드

Response 정보를 byte array로 변환한다.
길이가 아주 길고, 실제 크기를 알 수 없을 때 Response 개체의 stream을 처리하는 로직이 있음.
public static ResponseToArray ( WebResponse response ) : byte[]
response System.Net.WebResponse
리턴 byte[]

UploadFile() 공개 메소드

Client의 지정된 파일을 서버로 전송한다.
public UploadFile ( string filename, string method = "POST" ) : byte[]
filename string 서버로 전송할 파일명
method string Http communication method. (GET, POST, PUT...)
리턴 byte[]