2016-08-31 12 views
4

私がしようとすると、(100 MBを超える)非常に大きなファイルをダウンロードした場合、私はこのエラーを取得する:akkaのhttpクライアントで最大コンテンツ長を設定する方法は?

You can configure this by setting `akka.http.[server|client].parsing.max-content-length` or calling `HttpEntity.withSizeLimit` before materializing the dataBytes stream. 


val responseFuture: Future[HttpResponse] = 
    Http().singleRequest(HttpRequest(uri = "http://akka.io")) 

私は何とかwithoutSizeLimitにHttpEntityを設定することができることを読んでいた、私はこれをどのように行うことができますか?

akka.http.server.parsing.max-content-length=913753229 
akka.http.client.parsing.max-content-length=913753229 

答えて

0

私はakka.http.scaladsl.model.HttpEntitywithSizeLimit(maxBytes: Long)方法のソースコードのコメントに気づいた:

Note that the size limit applied via this method will only have any effect if the Source instance contained in this entity has been appropriately modified via the HttpEntity.limitable method. For all entities created by the HTTP layer itself this is always the case, but if you create entities yourself and would like them to properly respect limits defined via this method you need to make sure to apply HttpEntity.limitable yourself.

私はapplication.configにそれらのコンフィグ設定を追加する場合

ところで、それは問題を解決していません

HttpEntityオブジェクトで limitableByteSource()メソッドを秘密に変換してwithoutSizeLimitを有効にする必要があるかもしれません。いくつかの例があります:akka http doc

同じ問題が発生しましたが、ドキュメントではなぜwithSizeLimit()が機能しないのかについての有用性の低い情報があります。幸いにも、ソースコードは役に立つ情報を提供します:-)

関連する問題