dakrone / clj-http

An idiomatic clojure http client wrapping the apache client. Officially supported version.
http://clojars.org/clj-http
MIT License
1.78k stars 411 forks source link

Turn off lower-casing Headers #160

Closed mstang closed 10 years ago

mstang commented 11 years ago

Is it possible to turn off the automatic lower casing of headers? One of my co-workers wasn't aware of the case-insensitive requirement and add a Camel Case Header. And my choices are limited.

Thanks!

Mark

dakrone commented 11 years ago

It's currently not possible to turn it off, however, you can provide {:raw-headers true} with the request and get back the original headers in the :raw-headers key, would that work for you?

How is the lowercasing affecting you? According to the RFC, headers should always be case-insensitive, so sending them lowercase or camel case should both work.

mstang commented 11 years ago

I was afraid of that. One of my co-workers has created a requirement that certain header values be camel case (i.e. dppPersonUUID, authToken). My co-workers code is looking for dppPersonUUID in a map, so I would have to have it check for for both if I modified his code, in many places.

Using another REST tool I can use sends that value through unchanged. However, clj-http, turns it into dpppersonuuid and the software errors out. So, I can use clj-http for most of my REST tests, but for the other one I have to use other software. I considered cloning the repo, commenting out the lowercase calls and doing a local install. Haven't had time to do that.

Was hoping you might have a better solution :-)

regards,

Mark

On Tue, Sep 10, 2013 at 8:45 AM, Lee Hinman notifications@github.comwrote:

It's currently not possible to turn it off, however, you can provide {:raw-headers true} with the request and get back the original headers in the :raw-headers key, would that work for you?

How is the lowercasing affecting you? According to the RFC, headers should always be case-insensitive, so sending them lowercase or camel case should both work.

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-24165403 .

dakrone commented 10 years ago

@mstang just as a heads up, I believe @joegallo was working on a solution to this.

mstang commented 10 years ago

Wow, that would be great! I am continuing to use the library, however I am limited in the environments where I can use it. I have been thinking that I might have to switch to another library or create one of mine own.

I look forward to @joegallo solution.

regards,

Mark

On Sat, Dec 7, 2013 at 4:29 PM, Lee Hinman notifications@github.com wrote:

@mstang https://github.com/mstang just as a heads up, I believe @joegallo https://github.com/joegallo was working on a solution to this.

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-30069465 .

mstang commented 10 years ago

Hi All, I am considering switching off of clj-http as the library lower-cases header values. One of my co-workers, before he departed the company, put case-sensitive values into the system. So, when I try and send in values clj-http lower-cases them and then I get errors.

I had heard that @joegallo was working on a solution to this. Does anyone know if he ever fixed this?

If not, then I am thinking of switching to http-kit. I don't know if it does the same thing or not.

If I can't find a library, I may have to write my own .

regards,

Mark

On Sat, Dec 7, 2013 at 4:29 PM, Lee Hinman notifications@github.com wrote:

@mstang https://github.com/mstang just as a heads up, I believe @joegallo https://github.com/joegallo was working on a solution to this.

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-30069465 .

joegallo commented 10 years ago

I do solemnly swear that I shall finish my work on this tomorrow and put up a PR for @dakrone to review.

mstang commented 10 years ago

I have to wait until next year ;-)

On Tue, Dec 31, 2013 at 3:43 PM, Joe Gallo notifications@github.com wrote:

I do solemnly swear that I shall finish my work on this tomorrow and put a PR for @dakrone https://github.com/dakrone to review.

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-31414038 .

mstang commented 10 years ago

Hi All, Just wondering how I can get my hands on the changes? And once I do, how do I specify to not 'lower-case' the headers?

Thanks!

Mark

On Tue, Dec 31, 2013 at 3:43 PM, Joe Gallo notifications@github.com wrote:

I do solemnly swear that I shall finish my work on this tomorrow and put a PR for @dakrone https://github.com/dakrone to review.

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-31414038 .

joegallo commented 10 years ago

It's ended up being a little more complicated than I had hoped to get this finished, so still no PR. :(

I think today is the day, though.

When I get the PR up, I'll also push an artifact to clojars for you to try out. It'll be clj-http's current master + my changes. You'll be the vital first test case to figure out whether this stuff will actually help people out.

mstang commented 10 years ago

Hey Joe, Thanks! I look forward to being the "alpha" tester! Is the feature "on" by default? Is there an example?

Thanks!

Mark

On Thu, Jan 2, 2014 at 6:05 AM, Joe Gallo notifications@github.com wrote:

It's ended up being a little more complicated than I had hoped to get this finished, so still no PR. :(

I think today is the day, though.

When I get the PR up, I'll also push an artifact to clojars for you to try out. It'll be clj-http's current master + my changes. You'll be the vital first test case to figure out whether this stuff will actually help people out.

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-31451495 .

joegallo commented 10 years ago

I've got a version published to clojars as [joegallo/clj-http "0.7.9-SNAPSHOT"].

There's no particular example just yet -- all you need to do is use clj-http as you did before. The change is that headers that are sent or received by clj-http will be wrapped in a map implementation that treats keys as case-insensitive -- so if the server responds with a "Date" header, you could look that up as "date", "Date", :date, "datE", etc. String keys in request headers will be sent to the server with the casing that you used. Keyword keys in request headers will be transmogrified into the ordinary expected case: so :date becomes "Date", and :foo-bar becomes "Foo-Bar", but :content-md5 will become "Content-MD5" (because magic!).

mstang commented 10 years ago

Great, I will give it a shot! Thanks for all your effort!

regards,

Mark

On Fri, Jan 3, 2014 at 7:05 AM, Joe Gallo notifications@github.com wrote:

I've got a version published to clojars as [joegallo/clj-http "0.7.9-SNAPSHOT"].

There's no particular example just yet -- all you need to do is use clj-http as you did before. The change is that headers that are sent or received by clj-http will be wrapped in a map implementation that treats keys as case-insensitive -- so if the server responds with a "Date" header, you could look that up as "date", "Date", :date, "datE", etc. String keys in request headers will be sent to the server with the casing that you used. Keyword keys in request headers will be transmogrified into the ordinary expected case: so, :date become "Date", and :foo-bar becomes "Foo-Bar", but :content-md5 will become "Content-MD5" (because magic!).

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-31523996 .

mstang commented 10 years ago

Hey Joe, So far, so good! I am using lower AND upper case and no problems ;-)

Thanks!

Mark

On Fri, Jan 3, 2014 at 7:10 AM, Mark Stang markjstang@gmail.com wrote:

Great, I will give it a shot! Thanks for all your effort!

regards,

Mark

On Fri, Jan 3, 2014 at 7:05 AM, Joe Gallo notifications@github.comwrote:

I've got a version published to clojars as [joegallo/clj-http "0.7.9-SNAPSHOT"].

There's no particular example just yet -- all you need to do is use clj-http as you did before. The change is that headers that are sent or received by clj-http will be wrapped in a map implementation that treats keys as case-insensitive -- so if the server responds with a "Date" header, you could look that up as "date", "Date", :date, "datE", etc. String keys in request headers will be sent to the server with the casing that you used. Keyword keys in request headers will be transmogrified into the ordinary expected case: so, :date become "Date", and :foo-bar becomes "Foo-Bar", but :content-md5 will become "Content-MD5" (because magic!).

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-31523996 .

joegallo commented 10 years ago

Cool, glad to hear it -- is this solving the problem you had, and is there anything else you need w.r.t. clj-http's handling of headers?

mstang commented 10 years ago

Yes, it is solving my problem. I have one more header that I need to test with, but I don't think it will fail. I am able to send in headers that are camel-case, which I couldn't do before.

Thanks!

Mark

On Sat, Jan 4, 2014 at 4:46 PM, Joe Gallo notifications@github.com wrote:

Cool, glad to hear it -- is this solving the problem you had, and is there anything else you need w.r.t. clj-http's handling of headers?

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-31592086 .

joegallo commented 10 years ago

Please give 0.9.0-SNAPSHOT a try, my header-map work landed in master earlier today.

mstang commented 10 years ago

Thanks! I will give it a try!

regards,

Mark

On Thu, Feb 6, 2014 at 12:15 PM, Joe Gallo notifications@github.com wrote:

Please give 0.9.0-SNAPSHOT a try, my header-map work landed in master earlier today.

Reply to this email directly or view it on GitHubhttps://github.com/dakrone/clj-http/issues/160#issuecomment-34359238 .