Main Content

matlab.net.http.field.ContentLengthField 클래스

네임스페이스: matlab.net.http.field
슈퍼클래스: matlab.net.http.HeaderField, matlab.net.http.field.IntegerField

HTTP의 Content-Length 필드

설명

ContentLengthField 객체는 요청 메시지나 응답 메시지에 포함되는 HTTP 헤더 필드입니다. 이 필드는 페이로드의 길이를 바이트 단위로 지정합니다.

MATLAB®에 사용하려면 페이로드가 있는 모든 아웃바운드 메시지는 Content-Length 필드를 포함해야 합니다. 메시지에 본문이 비어 있지 않은 채 포함된 경우, MATLAB은 데이터의 길이를 토대로 Content-Length 필드를 생성합니다. 그러나 청크 형식 데이터 전송의 경우에는 필드가 추가되지 않습니다. 자세한 내용은 RFC 7231, section 3.3.2. Content-Length(IETF®(Internet Engineering Task Force) 웹사이트)를 참조하십시오.

응답 메시지는 이 필드를 포함하거나 포함하지 않을 수 있습니다.

클래스 특성

Sealed
true

클래스 특성에 대한 자세한 내용은 클래스 특성 항목을 참조하십시오.

생성

설명

예제

obj = matlab.net.http.field.ContentLengthField(value)Value 속성을 value로 설정하여 Content-Length 헤더 필드를 생성합니다.

속성

모두 확장

헤더 필드 이름으로, 'Content-Length'로 지정됩니다.

특성:

GetAccess
public
SetAccess
public

페이로드 길이(단위: 바이트)로, 음수가 아닌 정수 또는 음수가 아닌 정수로 평가되는 문자열로 지정됩니다.

특성:

GetAccess
public
SetAccess
public
Dependent
true

메서드

모두 확장

예제

모두 축소

이 예제에서는 메시지의 Content-Length 필드를 읽는 방법을 보여줍니다.

import matlab.net.*;
import matlab.net.http.*;

httpsUrl = 'https://requestserver.mathworks.com';
uri = URI(strcat(httpsUrl, '/assets/computerVision.jpg'));
req = RequestMessage('GET');
response = req.send(uri);
contentLengthField = response.getFields("Content-Length");
disp(contentLengthField)
  ContentLengthField with properties:

     Name: "Content-Length"
    Value: "102297"

버전 내역

R2016b에 개발됨