问题标签 [clj-http]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1075 浏览

oauth - How to wrap oAuth headers in clj-http?

I'm trying to post a twitter status update with clojure... but this probably really is a question about oAuth headers, and using it through the wonderful clj-http library.

I've used clj-http before for basic-auth and other type of headers and it was fairly straightforward. The Authorization: Bearer ... was a bit confusing but I got there in the end.

For twitter though, I am supposed to pass a lot of variables in Authorization and I am not quite sure how I'd go about doing that. Here's the curl command, according to twitter, that I'll need to post the tweet:

So I am not sure how I would append all the oAuth... things in the header. trying with (str ..) isn't really working out. Here's what I've got so far:

This returns 403. permission error when I try.

Any ideas on how I'd construct that query?

ps: I do have the oAuth token and token_secret for the account... but I notice the token_secret value isn't being passed? and what does oauth_nonce for? I'm for now passing the value that twitter gave me for curl... looking around it seems that it is just a random value so not that fussed about it.

0 投票
2 回答
273 浏览

clojure - 在 clojure 中处理 uncaught_exception

我的项目中有一个 clojure 端点,它基本上更新了 couchdb 中的文档。

当存在文档冲突以及异常原因时,此端点会引发 500 未捕获的异常,这会记录在日志文件中。跟踪重定向包含敏感信息。我添加了一个 catch 块来处理这个异常 [clojure.lang.ExceptionInfo]。它没有用。

我该如何处理?有没有办法删除跟踪重定向?

更新:道歉。即使发布了有效的 json 以进行更新,也会发生此错误。抱歉,如果这具有误导性。

  • 谢谢
0 投票
2 回答
565 浏览

json - clj-http/get url {:as :json} 在脚本中但在 REPL 中不起作用

我正在试验 Clojure 和 Leiningen。我成功执行到 REPL 中的以下行:

我创建了一个项目lein new http。当我运行以下几行时lein run,对 JSON 的强制不起作用。它只是打印一个正确的 JSON 字符串。

脚本的输出是

知道有什么问题吗?

0 投票
1 回答
712 浏览

https - clojure https 使用 TLS 1.2 协议连接

尝试使用 TLS 1.2连接到 https 服务器 ( https://3dsecure.kkb.kz )。

收到错误“javax.net.ssl.SSLException:收到致命警报:protocol_version”

openssl 1.0.1g,Java 7。

任何想法出了什么问题?

0 投票
1 回答
170 浏览

java - 无法解析 clj-http

我想使用 clj-http,所以我用 lein 创建了一个项目,其中包含以下依赖项project.clj

src/app/core.clj

当我使用时lein clean && lein deps && lein run,我收到一条错误消息:

lein version输出:

Leiningen 2.5.3 on Java 1.8.0_45 Java HotSpot(TM) 64-Bit Server VM

我做错了什么吗?我完全遵循了 clj-http 文档。

谢谢你。

0 投票
1 回答
805 浏览

clojure - 如何在clojure中的clj-http中指定http或https代理

在这个 url 中,它展示了如何在 clj-http 中使用代理

https://github.com/dakrone/clj-http

但是既然我们可以有http代理或者https代理,那么如何指定http或者https呢?或者现在不需要提供http或https就足够了?

0 投票
1 回答
1093 浏览

api - 如何使用包含 api 密钥的 clj-http 执行 http 请求?

我正在尝试向 api 发出 http 请求,将给定的句子更改为 yoda 可能会说的方式。这是我的代码,当前出现包含“缺少 Mashape 应用程序密钥”的错误:

:basic-auth部分是此代码中最有问题的部分。api 描述位于此处:https ://market.mashape.com/ismaelc/yoda-speak 这是此 api 的工作 curl 请求的样子:

任何帮助都可能为我节省无数时间,让我在谷歌上寻找有关如何完成此操作的线索。

0 投票
1 回答
247 浏览

clojure - clj-http:跟踪多部分文件上传的进度

我正在使用clj-http进行多部分文件上传。我想知道是否有一种方法可以跟踪文件上传的进度。也许,一些函数会定期调用,到目前为止已经上传了多少文件?

0 投票
1 回答
1784 浏览

json - clj-http 不返回 JSON

我正在尝试使用 clj-http 版本 2.2.0 从 REST 资源中读取 JSON,但无论我做什么,我都会将结果作为字符串。

在调试时,我在https://nym.at/test.json上的网络服务器上将我对这个请求的操作剥离到一个静态 JSON 文档:

我在 REPL 中运行以下代码(client绑定到命名空间 clj-http.client):

我得到的结果是(手动打印):

我的期望是否错误,{:as :json}应该导致 clj-http 将响应解析为 JSON 并将其返回,:body或者我在这里做错了什么?

0 投票
0 回答
428 浏览

ssl - clj-http get request: SSLException

I'm having troubles accessing a https url via a clj-http get-request.

The same URL works perfectly with a simple curl request. In clojure, I just get it working when using the :insecure? true flag.

Here's the error I get otherwise: