Skip to content

Instantly share code, notes, and snippets.

@daemin-hwang
Last active June 10, 2016 09:06
Show Gist options
  • Select an option

  • Save daemin-hwang/e3d334a6db96da3b3807a4e4765c813b to your computer and use it in GitHub Desktop.

Select an option

Save daemin-hwang/e3d334a6db96da3b3807a4e4765c813b to your computer and use it in GitHub Desktop.
ClientHttpRequestInterceptor 구현시 주의사항
ClientHttpRequestInterceptor를 구현하여
request 와 response를 핸들하는 경우.
request를 조회하는것은 문제가 없지만
response의 경우 인터셉터의 프로세스를 수행 후
인풋스트림이 닫히기 때문에 getBody() 에서 얻어올 컨텐츠 타입이 null포인터 익셉션이 발생한다.
RestTemplate에 생성자로 BufferingClientHttpRequestFactory타입의 클래스를 넘겨주어야만 위와 같은 현상을 피할 수 있다.
BufferingClientHttpRequestFactory 는 HttpComponentsClientHttpRequestFactory 를 주입받는다
내가 삽질/고민하던 결과를 아래 참조링크의 개발자분이 잘 정리해주셨다 ㅠ
참조링크 :
http://lng1982.tistory.com/238
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment