본문 바로가기

전력프로토콜

http chunked 와 Http Content-Length 의 비교

반응형

Normal Http

Chunked Http

해더 속성

HTTP/1.1 200 OK

Date: Sat, 03 Dec 2005 15:10:17 GMT

Server: Secured

Last-Modified: Sun, 18 Jan 2004 20:26:49 GMT

ETag: "64151-7dc-400aec09"

Accept-Ranges: bytes

Content-Length: 2012 <-- contents의 길이. 2012bytes

Connection: close

Content-Type: text/plain

HTTP/1.1 200 OK

Date: Sat, 03 Dec 2005 16:29:25 GMT

Server: Secured

Transfer-Encoding: chunked <-- chunked encoding

Content-Type: text/html

Http Header에 Content-Length 가 있다면, Content-Length에 적혀져 있는 길이만큼은 Body부분에서 수신한다.

보낼 양이 많을 경우 분할 하여 보낼 때 사용한다

예제

<html xmlns="http://www.w3.org/1999/xhtml">

<head profile="http://a9.com/-/spec/opensearch/1.1/">

<meta http-equiv="Content-Type" content="text/html;charset=euc-kr" />

<meta name="autocomplete" content="off" />

<title>Daum 에러페이지 | 페이지를 찾을 수 없음</title>

<body>

................

................

................

<body>

</html>

100 bytes 송신 시. (서버 설정치:40바이트)

 

1)

>40 (보낸 데이터의 크기_본래 16진수로 표시한다.)

>컨텐츠(40bytes)

>60 (남은 데이터의 크기)

 

2)

>40 (보낸 데이터의 크기)

>컨텐츠(40bytes)

>20 (남은 데이터의 크기)

 

3)

>20 (보낸 데이터의 크기)

>컨텐츠(20bytes)

>0 (남은 데이터의 크기)

특징

파일의 길이를 알아야 한다.

- 파일의 길이를 알 필요가 없다.

- 동적으로 생성하는 자원을 전송시 유용하다.

byte로 전송

chunk(덩어리로 전송)

 

끝은 CRLF, 길이가 0인 chunked를 보냄, 수신함으로 끝을 나타낸다.


'전력프로토콜' 카테고리의 다른 글

DNP3.0 공부  (1) 2016.09.08
[데이터통신] null modem??  (1) 2011.03.16