0

play 2.5.x ws library 을 사용하여 내부 서버에 파일을 업로드합니다. apache http/curl/postman에서 작동하는 샘플 코드가 있습니다. 하지만 내가 ws 라이브러리를 사용하려고 할 때 어떻게 실패하는지. 나는 내부 서버에 액세스 할 수 없습니다와 내가 모두 요청에서 (아파치 HTTP/재생 WS를) 요청 헤더를 검사 한 오류 메시지자바 재생 프레임 워크 http 요청에서 콘텐츠 길이 헤더 설정

을 반환하지 내가 "콘텐츠 길이"헤더 가없는 것을 볼 수 WS 요청에서. 내가

ws.url(url).setHeader().post(Source.from(Arrays.asList(fp,name) 

로를 설정하려고하지만

"Stream has already been consumed and cannot be reset" 

을 얻고 난 콘텐츠 길이를 설정할 수있는 방법이 있습니까?. 또는 내가 빠진 것이 더 있습니다.

답변

0

불행히도,이 제대로 문서화되어 있지 않습니다,하지만 당신은 look at the codepost(Source) 작동 방법을 이해하는 것이 :

// If the body has a streaming interface it should be up to the user to provide a manual Content-Length 
// else every content would be Transfer-Encoding: chunked 
// If the Content-Length is -1 Async-Http-Client sets a Transfer-Encoding: chunked 
// If the Content-Length is great than -1 Async-Http-Client will use the correct Content-Length 

-1가 기본값입니다.

현재로서는 Content-Length을 설정하거나 서버가 청크 분할 전송을 허용하도록합니다.