나는 이미지 호스트 서비스에 대한 응답의 내용 유형을 설정하기 위해 노력하고있어, 그래서는 HTTP 가지고 다음과 같습니다 인바운드 게이트웨이 :스프링 통합 http 인바운드 게이트웨이 매핑 된 응답 헤더 - 복제 중입니까?
<int-http:inbound-gateway request-channel="receiveChannel"
reply-channel="responseChannel"
path="/profile/photo"
mapped-response-headers="Content-Type"
message-mappers="messageConverterList"
supported-methods="GET"/>
... 그리고 서비스 활성화를이
<int:service-activator
input-channel="receiveChannel"
output-channel="imageResponseChannel"
expression="@profileService.getPhoto(payload.userId)"/>
... jpeg 이미지 데이터의 바이트 []를 반환합니다. 나는이처럼 보이는 헤더 enricher 있습니다
<int:header-enricher
input-channel="imageResponseChannel"
output-channel="responseChannel">
<int:header
name="Content-Type"
expression="'image/jpeg'"/>
</int:header-enricher>
을하지만이 프로젝트를 실행할 때이 같은 헤더와 응답 수 :
이< HTTP/1.1 200 OK
< Set-Cookie: JSESSIONID=9uw5c136fia6s9ivxgivy1yc;Path=/
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Content-Type: image/jpeg
< Content-Type: application/octet-stream
< Content-Length: 6563
< Server: Jetty(8.1.3.v20120416)
공지 콘텐츠 형식이 반복된다,하지만 그건 매핑 된 응답 헤더는 메시지의 헤더를 가져 와서 페이로드에서 확인하지 않아야한다는 것을 이해합니다.
아이디어가 있으십니까? 미리 감사드립니다!
* EDIT : 아래의 사용자 지정 메시지 - 맵퍼를 참조하도록 인바운드 게이트웨이를 변경했지만 여전히 동일한 결과를 얻습니다.
<util:list id="messageConverterList">
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter">
<property name="supportedMediaTypes">
<list><value>image/jpeg</value></list>
</property>
</bean>
</util:list>
* 편집 2 :이되어 메시지 컨버터가 있어야 밝혀,하지만 대상이 아닌 SRC에서 파일을 수정하기 때문에 오류가 발생하지 않았다. 나는 수정했고 이것은 내가 얻는 결과이다 :
< HTTP/1.1 200 OK
< Content-Type: image/jpeg
< Content-Type: image/jpeg
< Content-Length: 209582
< Server: Jetty(6.1.10)
더 좋지만 완벽하지는 않다. http://dl.dropbox.com/u/92800052/http.tar.gz
당신이
mvn package jetty:run
그것을 실행하고 (핵심 봄 웹 lib 디렉토리에서) 기본적으로 여러 HttpMessageConverters으로
curl -v http://localhost:8080/http/photo > /dev/null
확실히. 2.1.3.RELEASE를 사용하고 있습니다. 내가 추가 한 코드는 결과와 함께 EDIT에 있습니다 (주석에 코드를 추가 할 수 없기 때문에). – Joe
더 많은 것을 시도해 볼 수 있습니까? header-enricher에서 "content-type"대신 대문자 대신 소문자를 사용할 수 있습니까? – mfisher
난 그냥 헤더 enricher의 낮은 케이싱 콘텐츠 유형을 시도한 다음 동일한 결과 (중복 된 Content-Type HTTP 헤더)가있는 게이트웨이에서 시도했다. 프로젝트의 새 니타이션 버전을 만들어 github에 게시 할 수 있습니다. 그게 도움이 될 것이라고 생각하니? – Joe