Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用调度将 HTTP GET 请求的响应下载为 Scala 中的 Array[Byte],但文档没有帮助,在线搜索也没有帮助。此外,我需要在响应中检索标头的值。
谁能提供一个工作片段,可能带有自定义标题?
提前致谢!
想出了我自己的方法:
val (someHeaderVal, buf) = Http x (url(fileUrl) <:< Map("ACustomHeader" -> "MyValue") >:+ { (headers, req) => req >> { stream => (headers("ResponseCustomHeader").head, IOUtils.toByteArray(stream)) } })
这似乎工作得很好。