0

我正在使用play 2.5.x ws library 將文件上傳到內部服務器。 我有示例代碼與Apache HTTP /捲曲/郵遞員工作。 但是,當我嘗試使用ws庫一些如何失敗。 我沒有訪問內部服務器,我已經從兩個請求檢查請求頭(的Apache HTTP /播放WS),它沒有返回任何錯誤消息在java play framework 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 code瞭解如何post(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或讓您的服務器接受分塊傳輸。