當使用帶有Restlet 1.1的Apache HTTP客戶端庫4.x時,我收到了一個間歇性異常org.apache.commons.httpclient.ProtocolException: Unbuffered entity enclosing request can not be repeated.
。請求實體類型爲InputRepresentation
,它與已知大小的ByteArrayInputStream
相關聯,其大小在實例化時指定。可以將Restlet配置爲使用BufferedHttpEntity?
的拋出異常在方法writeRequestBody
類org.apache.commons.httpclient.methods.EntityEnclosingMethod
if ((this.repeatCount > 0) && !requestEntity.isRepeatable()) {
throw new ProtocolException(
"Unbuffered entity enclosing request can not be repeated.");
}
坦率地說,此異常的原因尚不清楚(特別是由於它的間歇性)。但是,一些研究表明,使用Apache BufferedHttpEntity來封裝請求實體應該有所幫助。
有沒有辦法通知Restlet在將請求傳遞到Apache庫進行處理時使用BufferedHttpEntity?什麼可能是問題的原因?
+1不幸的是,我不得不使用Restlet抽象,不提供對HttpEntity的訪問。但是,檢查依賴關係的想法很有價值 - 事實證明,Restlet 1.x提供了它自己對Apache HTTP Client版本3.1的依賴。 – 01es
@ 01es我試圖做的一點是,沒有理由讓一個字節數組支持的實體不可重複,並且整個問題可能是Restlet 1.1中的一個錯誤 – oleg