2017-02-06 3 views
5

HttpResponseMessage에서 Content-Encoding을 설정하려고합니다. 이 WebApi 작업을 감안할 때HttpResponseMessage에서 콘텐츠 인코딩을 설정하는 방법

public HttpResponseMessage Get() 
{ 
    byte[] tile = GetTile(); 

    var result = new HttpResponseMessage(HttpStatusCode.OK) {Content = new ByteArrayContent(tile)}; 

    result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-protobuf"); 

    return result; 
} 

헤더의 Content-Encoding을 gzip으로 설정하려면 어떻게해야합니까?

result.Content.Headers.ContentEncoding 

은 읽기 전용입니다.

답변

6

ContentEncoding 속성은 ICollection의 인스턴스입니다. 이는 내용을 제어하기위한 추가 및 지우기 메소드를 제공합니다.

+0

죄송합니다, 당황 말하는 가치가 그렇게 같은 실수를 다른 사람이해야합니다가 몇 표와 방문을 받고있다. 긴 하루. 감사 – dibs487

1

리치 질라의 대답은 물론 정확하고 내 질문에 답하지 않아야합니다. 이로 보는 것은 내가 내 문제에 대한 완전한 답이 방법

result.Content.Headers.ContentEncoding.Add("gzip"); 
관련 문제