Skip to content

Commit 79ca335

Browse files
committed
Release 1.0.0. Move ns to clojure-http.client!
Add rebindable *buffer-size* for copying request bodies.
1 parent 67b4e08 commit 79ca335

File tree

8 files changed

+293
-105
lines changed

8 files changed

+293
-105
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ lib
44
classes
55
*.jar
66
Manifest.txt
7+
autodoc

COPYING

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
Eclipse Public License - v 1.0
2+
3+
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
4+
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
5+
THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6+
7+
1. DEFINITIONS
8+
9+
"Contribution" means:
10+
11+
a) in the case of the initial Contributor, the initial code and
12+
documentation distributed under this Agreement, and
13+
14+
b) in the case of each subsequent Contributor:
15+
16+
i) changes to the Program, and
17+
18+
ii) additions to the Program;
19+
20+
where such changes and/or additions to the Program originate from and
21+
are distributed by that particular Contributor. A Contribution
22+
'originates' from a Contributor if it was added to the Program by such
23+
Contributor itself or anyone acting on such Contributor's
24+
behalf. Contributions do not include additions to the Program which:
25+
(i) are separate modules of software distributed in conjunction with
26+
the Program under their own license agreement, and (ii) are not
27+
derivative works of the Program.
28+
29+
"Contributor" means any person or entity that distributes the Program.
30+
31+
"Licensed Patents" mean patent claims licensable by a Contributor
32+
which are necessarily infringed by the use or sale of its Contribution
33+
alone or when combined with the Program.
34+
35+
"Program" means the Contributions distributed in accordance with this
36+
Agreement.
37+
38+
"Recipient" means anyone who receives the Program under this
39+
Agreement, including all Contributors.
40+
41+
2. GRANT OF RIGHTS
42+
43+
a) Subject to the terms of this Agreement, each Contributor hereby
44+
grants Recipient a non-exclusive, worldwide, royalty-free copyright
45+
license to reproduce, prepare derivative works of, publicly display,
46+
publicly perform, distribute and sublicense the Contribution of such
47+
Contributor, if any, and such derivative works, in source code and
48+
object code form.
49+
50+
b) Subject to the terms of this Agreement, each Contributor hereby
51+
grants Recipient a non-exclusive, worldwide, royalty-free patent
52+
license under Licensed Patents to make, use, sell, offer to sell,
53+
import and otherwise transfer the Contribution of such Contributor, if
54+
any, in source code and object code form. This patent license shall
55+
apply to the combination of the Contribution and the Program if, at
56+
the time the Contribution is added by the Contributor, such addition
57+
of the Contribution causes such combination to be covered by the
58+
Licensed Patents. The patent license shall not apply to any other
59+
combinations which include the Contribution. No hardware per se is
60+
licensed hereunder.
61+
62+
c) Recipient understands that although each Contributor grants the
63+
licenses to its Contributions set forth herein, no assurances are
64+
provided by any Contributor that the Program does not infringe the
65+
patent or other intellectual property rights of any other entity. Each
66+
Contributor disclaims any liability to Recipient for claims brought by
67+
any other entity based on infringement of intellectual property rights
68+
or otherwise. As a condition to exercising the rights and licenses
69+
granted hereunder, each Recipient hereby assumes sole responsibility
70+
to secure any other intellectual property rights needed, if any. For
71+
example, if a third party patent license is required to allow
72+
Recipient to distribute the Program, it is Recipient's responsibility
73+
to acquire that license before distributing the Program.
74+
75+
d) Each Contributor represents that to its knowledge it has sufficient
76+
copyright rights in its Contribution, if any, to grant the copyright
77+
license set forth in this Agreement.
78+
79+
3. REQUIREMENTS
80+
81+
A Contributor may choose to distribute the Program in object code form
82+
under its own license agreement, provided that:
83+
84+
a) it complies with the terms and conditions of this Agreement; and
85+
86+
b) its license agreement:
87+
88+
i) effectively disclaims on behalf of all Contributors all warranties
89+
and conditions, express and implied, including warranties or
90+
conditions of title and non-infringement, and implied warranties or
91+
conditions of merchantability and fitness for a particular purpose;
92+
93+
ii) effectively excludes on behalf of all Contributors all liability
94+
for damages, including direct, indirect, special, incidental and
95+
consequential damages, such as lost profits;
96+
97+
iii) states that any provisions which differ from this Agreement are
98+
offered by that Contributor alone and not by any other party; and
99+
100+
iv) states that source code for the Program is available from such
101+
Contributor, and informs licensees how to obtain it in a reasonable
102+
manner on or through a medium customarily used for software exchange.
103+
104+
When the Program is made available in source code form:
105+
106+
a) it must be made available under this Agreement; and
107+
108+
b) a copy of this Agreement must be included with each copy of the Program.
109+
110+
Contributors may not remove or alter any copyright notices contained
111+
within the Program.
112+
113+
Each Contributor must identify itself as the originator of its
114+
Contribution, if any, in a manner that reasonably allows subsequent
115+
Recipients to identify the originator of the Contribution.
116+
117+
4. COMMERCIAL DISTRIBUTION
118+
119+
Commercial distributors of software may accept certain
120+
responsibilities with respect to end users, business partners and the
121+
like. While this license is intended to facilitate the commercial use
122+
of the Program, the Contributor who includes the Program in a
123+
commercial product offering should do so in a manner which does not
124+
create potential liability for other Contributors. Therefore, if a
125+
Contributor includes the Program in a commercial product offering,
126+
such Contributor ("Commercial Contributor") hereby agrees to defend
127+
and indemnify every other Contributor ("Indemnified Contributor")
128+
against any losses, damages and costs (collectively "Losses") arising
129+
from claims, lawsuits and other legal actions brought by a third party
130+
against the Indemnified Contributor to the extent caused by the acts
131+
or omissions of such Commercial Contributor in connection with its
132+
distribution of the Program in a commercial product offering. The
133+
obligations in this section do not apply to any claims or Losses
134+
relating to any actual or alleged intellectual property
135+
infringement. In order to qualify, an Indemnified Contributor must: a)
136+
promptly notify the Commercial Contributor in writing of such claim,
137+
and b) allow the Commercial Contributor tocontrol, and cooperate with
138+
the Commercial Contributor in, the defense and any related settlement
139+
negotiations. The Indemnified Contributor may participate in any such
140+
claim at its own expense.
141+
142+
For example, a Contributor might include the Program in a commercial
143+
product offering, Product X. That Contributor is then a Commercial
144+
Contributor. If that Commercial Contributor then makes performance
145+
claims, or offers warranties related to Product X, those performance
146+
claims and warranties are such Commercial Contributor's responsibility
147+
alone. Under this section, the Commercial Contributor would have to
148+
defend claims against the other Contributors related to those
149+
performance claims and warranties, and if a court requires any other
150+
Contributor to pay any damages as a result, the Commercial Contributor
151+
must pay those damages.
152+
153+
5. NO WARRANTY
154+
155+
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
156+
PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
157+
KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
158+
WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
159+
OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
160+
responsible for determining the appropriateness of using and
161+
distributing the Program and assumes all risks associated with its
162+
exercise of rights under this Agreement , including but not limited to
163+
the risks and costs of program errors, compliance with applicable
164+
laws, damage to or loss of data, programs or equipment, and
165+
unavailability or interruption of operations.
166+
167+
6. DISCLAIMER OF LIABILITY
168+
169+
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
170+
ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
171+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
172+
WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
173+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
174+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
175+
DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
176+
HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
177+
178+
7. GENERAL
179+
180+
If any provision of this Agreement is invalid or unenforceable under
181+
applicable law, it shall not affect the validity or enforceability of
182+
the remainder of the terms of this Agreement, and without further
183+
action by the parties hereto, such provision shall be reformed to the
184+
minimum extent necessary to make such provision valid and enforceable.
185+
186+
If Recipient institutes patent litigation against any entity
187+
(including a cross-claim or counterclaim in a lawsuit) alleging that
188+
the Program itself (excluding combinations of the Program with other
189+
software or hardware) infringes such Recipient's patent(s), then such
190+
Recipient's rights granted under Section 2(b) shall terminate as of
191+
the date such litigation is filed.
192+
193+
All Recipient's rights under this Agreement shall terminate if it
194+
fails to comply with any of the material terms or conditions of this
195+
Agreement and does not cure such failure in a reasonable period of
196+
time after becoming aware of such noncompliance. If all Recipient's
197+
rights under this Agreement terminate, Recipient agrees to cease use
198+
and distribution of the Program as soon as reasonably
199+
practicable. However, Recipient's obligations under this Agreement and
200+
any licenses granted by Recipient relating to the Program shall
201+
continue and survive.
202+
203+
Everyone is permitted to copy and distribute copies of this Agreement,
204+
but in order to avoid inconsistency the Agreement is copyrighted and
205+
may only be modified in the following manner. The Agreement Steward
206+
reserves the right to publish new versions (including revisions) of
207+
this Agreement from time to time. No one other than the Agreement
208+
Steward has the right to modify this Agreement. The Eclipse Foundation
209+
is the initial Agreement Steward. The Eclipse Foundation may assign
210+
the responsibility to serve as the Agreement Steward to a suitable
211+
separate entity. Each new version of the Agreement will be given a
212+
distinguishing version number. The Program (including Contributions)
213+
may always be distributed subject to the version of the Agreement
214+
under which it was received. In addition, after a new version of the
215+
Agreement is published, Contributor may elect to distribute the
216+
Program (including its Contributions) under the new version. Except as
217+
expressly stated in Sections 2(a) and 2(b) above, Recipient receives
218+
no rights or licenses to the intellectual property of any Contributor
219+
under this Agreement, whether expressly, by implication, estoppel or
220+
otherwise. All rights in the Program not expressly granted under this
221+
Agreement are reserved.
222+
223+
This Agreement is governed by the laws of the State of Washington and
224+
the intellectual property laws of the United States of America. No
225+
party to this Agreement will bring a legal action under this Agreement
226+
more than one year after the cause of action arose. Each party waives
227+
its rights to a jury trial in any resulting litigation.

README.markdown

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,32 @@
22

33
by Dan Larkin and Phil Hagelberg
44

5-
A work in progress.
5+
Note: In the 1.0.0 release the namespace changed from clojure.http to
6+
clojure-http; please update your require clauses accordingly.
67

7-
There are two namespaces, clojure.http.client, which provides a simple
8-
"request" function, and clojure.http.resourcefully, which is targeted
8+
## Example
9+
10+
There are two namespaces, clojure-http.client, which provides a simple
11+
"request" function, and clojure-http.resourcefully, which is targeted
912
more towards interactions with REST-based APIs.
1013

11-
(ns clojure.http.example
12-
(:use [clojure.http.client]
14+
(ns clojure-http.example
15+
(:use [clojure-http.client]
1316
[clojure.contrib.json.write])
14-
(:require [clojure.http.resourcefully :as resourcefully]))
17+
(:require [clojure-http.resourcefully :as res]))
1518

1619
(let [response (request "http://google.com")]
1720
(:code response) ;; 200
1821
(:msg response) ;; "OK"
1922
(:body-seq response)) ;; ("<html><head><meta[...]" ...
2023

21-
(resourcefully/put "http://localhost:5984/my-db/doc1"
22-
{} (json-str {:hello "world"}))
24+
(resurcefully/put "http://localhost:5984/my-db/doc1"
25+
{} (json-str {:hello "world"}))
2326

24-
(resourcefully/with-cookies {}
25-
(resourcefully/post "http://localhost:3000/login"
26-
{} {"user" user "password" password})
27-
(resourcefully/get "http://localhost:3000/my-secret-page))
27+
(res/with-cookies {}
28+
(res/post "http://localhost:3000/login"
29+
{} {"user" user "password" password})
30+
(res/get "http://localhost:3000/my-secret-page))
2831

2932
The request function requires a URL and optionally accepts a method
3033
(GET by default), a map of headers, a map of cookies, and a request
@@ -33,19 +36,25 @@ and an optional body.
3336

3437
Request bodies may be strings, maps, or InputStreams. Strings get sent
3538
verbatim. Maps get sent as application/x-www-form-urlencoded, and
36-
InputStreams get streamed to the server 1000 bytes at a time.
39+
InputStreams get streamed to the server 1024 bytes at a time, though
40+
this can be changed by rebinding \*buffer-size\*.
41+
42+
## Usage
3743

3844
The functions in resourcefully are named after the HTTP verbs. Note
39-
that resourcefully must be required :as something since it defines a
40-
"get" function, which would interfere with core if it were fully
41-
referred. Exceptions will be raised for status codes that indicate
42-
problems, so you don't have to check return codes manually. If you use
43-
resourcefully inside a "with-cookies" block, cookies will
44-
automatically be saved in a *cookies* ref and sent out with each
45-
request.
46-
47-
TODO:
45+
that resourcefully must be required with the :as option since it
46+
defines a "get" function, which would interfere with clojure.core if
47+
it were fully referred. Exceptions will be raised for status codes
48+
that indicate problems, so you don't have to check return codes
49+
manually. If you use resourcefully inside a "with-cookies" block,
50+
cookies will automatically be saved in a *cookies* ref and sent out
51+
with each request.
52+
53+
## TODO
54+
4855
* Connection pooling/keep-alive?
49-
* Anything else? Send a message via github or the Clojure mailing list.
56+
* Anything else? Send a message via Github or the Clojure mailing list.
57+
58+
Copyright (c) 2009-2010 Dan Larkin and Phil Hagelberg
5059

51-
Licensed under the same terms as Clojure.
60+
Licensed under the same terms as Clojure. See COPYING

pom.xml

Lines changed: 0 additions & 46 deletions
This file was deleted.

project.clj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
(defproject clojure-http-client "1.0.0-SNAPSHOT"
1+
(defproject clojure-http-client "1.0.0"
22
:description "An HTTP client for Clojure."
3-
:dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
4-
[org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]]
5-
:dev-dependencies [[swank-clojure "1.1.0"]])
3+
:dev-dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
4+
[org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]
5+
[swank-clojure "1.2.1"]
6+
[autodoc "0.7.0"]])

0 commit comments

Comments
 (0)