简体   繁体   English

通过Clojure / Java中的自定义协议隧道HTTP

[英]Tunnelling HTTP over a custom protocol in Clojure/Java

I want to tunnel a HTTP request stream over a custom transport protocol. 我想通过自定义传输协议来隧穿HTTP请求流。 Are there any Clojure or, as a fallback, Java HTTP clients that'd let me access the underlying request streams or lets me filter the serialised requests and responses? 是否有任何Clojure或Java HTTP客户端作为后备,可以让我访问基础的请求流,或者让我过滤序列化的请求和响应?

I know clj-http wraps Apache HttpComponents, but doesn't seem to provide a lot of hooks into HC internals, and I've looked into HC itself, but have a hard time navigating the jungle of factories, interfaces and managers. 我知道clj-http包装了Apache HttpComponents,但是似乎并没有提供很多有关HC内部的信息,我研究了HC本身,但是很难在工厂,接口和管理者的丛林中穿行。

clj-http includes the ability to read to and write from an input stream clj-http包括读取和写入输入流的功能

(client/get "http://site.com/bigrequest.html" {:as :stream})

(client/post "http://site.com/resources"
         {:body (clojure.java.io/input-stream "/tmp/foo") :length 1000})

you can then wrap this stream in your transport of choice. 然后可以将此流包装在您选择的运输方式中。

You can have request body as stream. 您可以将请求正文作为流。 For that you need to set the :body value to any object that implements InputStream . 为此,您需要将:body值设置为实现InputStream任何对象。 Check the function wrap-input-coercion at https://github.com/dakrone/clj-http/blob/master/src/clj_http/client.clj for more details. 有关更多详细信息, 检查https://github.com/dakrone/clj-http/blob/master/src/clj_http/client.clj上的 wrap-input-coercion函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM