technomancy / clojure-http-client Goto Github PK
View Code? Open in Web Editor NEWAn HTTP client for Clojure (DEPRECATED)
License: Eclipse Public License 1.0
An HTTP client for Clojure (DEPRECATED)
License: Eclipse Public License 1.0
As far as I can see, clojure-http-client doesn't follow redirects and there is no way to make it do so. IMHO, there should be an optional parameter which would enable that.
I think HTTP header names are supposed to be case-insensitive. A server I was working with sent "Set-cookie" instead of "Set-Cookie". I changed the header map to use downcased keywords instead of strings, so e.g. (:content-type headers) instead of (headers "Content-Type"). Not sure about what's best to do here since this breaks backwards compatibility. Also, the request header map has string keys, and it seems strange to have string keys there but keyword keys in the response header map.
My backwards incompatible fix is http://github.com/tomo/clojure-http-client/commit/6becb1a805f25ee5a05490b08b56ba750a57c5c8. It might even break something I'm not using in clojure-http-client itself (resourcefully?), not sure.
clojure-http-client somehow loses all the cookies when following a redirect issued by the server. The cookies returned by the server in the first response should be maintained while following redirects if possible, else there should be a way to prevent it from following redirects.
Servers might send multiple Set-Cookie headers, but clojure-http-client only takes the first (http://github.com/technomancy/clojure-http-client/blob/7b9715e2fa038369a65fed89011471f705dd537b/src/clojure/http/client.clj#L66)
This might apply to other headers, too, I suppose, but I ran into it because the server I was working with set multiple Set-Cookie headers. I'm not sure about the best way to solve this. I had line 66 above use (seq v)
instead of just v
, but this will screw up anyone currently accessing headers as just values.
If a server sets a cookie value that contains an "=", clojure-http-client can't handle it.
For example, http://www.google.com sets a cookie like "PREF=ID=...:TM=...:LM=...:S=...; expires=Wed, 31-Aug-2011 11:18:19 GMT; path=/; domain=.google.com"
(:cookies (request "http://www.google.com")) looks like
{"domain" ".google.com", "path" "/", "expires" "Wed, 31-Aug-2011 11:18:19 GMT", "PREF" "ID"}
This is a simple fix: http://github.com/tomo/clojure-http-client/commit/f416aaa1909491af3f5e1beb3f320567a23766b5
username like "[email protected]" are not properly encoded as I understand
I'm trying to make a request using HTTP Basic auth.
Here's what I'm doing:
(ns http-testcase
(:require [clojure.http.client :as http]))
(defn failure []
(prn (:body-seq (http/request "http://ieure:[email protected]/"))))
Fire up tcpdump:
$ sudo tcpdump -s0 -w atomized.cap -ien1 -f 'host atomized.org'
Run the code:
(failure)
If you examine the packet capture, there's no Authorization header:
GET / HTTP/1.1
User-Agent: Clojure/{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"} (+http://clojure.org)
Connection: close
Host: atomized.org
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
clojure.http.client is incompatible with the current 1.2 snapshot of contrib. Specifically, c.c.java-utils no longer exists, & as-str has been moved to c.c.string. duck-streams & str-utils still exist but are deprecated.The ns statement can be fixed by replacing the use statement:
(:use [clojure.contrib.java-utils :only [as-str]]
[clojure.contrib.duck-streams :only [read-lines spit]]
[clojure.contrib.str-utils :only [str-join]]
[clojure.contrib.base64 :as base64])
with
(:use [clojure.contrib.io :only [read-lines spit]]
[clojure.contrib.string :only [as-str join]]
[clojure.contrib.base64 :as base64])
(Note: c.c.str-utils/str-join => c.c.string/join)
Best,
Perry
I have URLs with ":name=value" in them and use clojure.http.client to retrieve them. It looks like url-encode uses "as-str" function whose semantics are to drop colon. I am curious to know if this behavior was intended. In any case, I think being able to use parameter names with leading/embedded ':' is legitimate and this gratuitous behavior of "as-str" forces me to duplicate url-encode.
Can you "Leiningeniize" this and push it to clojars?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.