作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用 Akka HTTP 向本地主机发送 get 请求,但出现以下异常:
EntityStreamSizeException: actual entity size (Some(10166731700)) exceeded content length limit (8388608 bytes)! You can configure this by setting akka.http.[server|client].parsing.max-content-length or calling HttpEntity.withSizeLimit before materializing the dataBytes stream.)
基本上,我尝试请求的本地主机上的文件非常大。
我尝试使用withoutSizeLimit
解决这个问题,但它不起作用:
val request = Get("http://localhost:8080/oa-ok.ntriples")
val limitedRequest = request.withEntity(request.entity.withoutSizeLimit())
val responseFuture = Http().singleRequest(limitedRequest)
我也尝试使用withSizeLimit
,但没有帮助。有什么想法吗?
最佳答案
在响应实体上使用 withoutSizeLimit
,而不是在请求实体上。例如:
val responseFuture: Future[HttpResponse] =
Http().singleRequest(HttpRequest(uri = "http://localhost:8080/oa-ok.ntriples"))
val responseSource: Source[ByteString, NotUsed] =
Source.fromFuture(responseFuture)
.flatMapConcat(_entity.withoutSizeLimit.dataBytes)
responseSource
是响应实体的 Akka Streams Source
。
关于scala - Akka HTTP 客户端 EntityStreamSizeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53191737/
我尝试使用 Akka HTTP 向本地主机发送 get 请求,但出现以下异常: EntityStreamSizeException: actual entity size (Some(10166731
我是一名优秀的程序员,十分优秀!