开发者

Why does rails make header content lowercase?

开发者 https://www.devze.com 2023-03-19 05:47 出处:网络
I find this behavior a bit strange, I\'m using \'net\\http\' to do some restful communication to an internal API. For this I need to send a multipart/form-data request to our server. In my code I have

I find this behavior a bit strange, I'm using 'net\http' to do some restful communication to an internal API. For this I need to send a multipart/form-data request to our server. In my code I have this:

request["Content-Type"] = "multipart/form-data, boundary=AbCdE1"

The request created then looks like this:

"multipart/form-data, boundary=abcde1"

The problem is the body itse开发者_JS百科lf is using AbCdE1 for its boundaries and it fails. Obviously I could use just lowercase letters, but for a more reliably unique boundary, having capitals is helpful. I have seen comments that rails makes headers lowercase, is there a good reason why it does this without my intervention?


The correct delimiter for the Content-Type and the boundary is a semicolon... Have you tried to use a semicolon instead of the comma, to see if Rails still translate it to lowercase?

BTW check http://httparty.rubyforge.org/ for consuming RESTful webservices, the result is more elegant than writing net/http code.

0

精彩评论

暂无评论...
验证码 换一张
取 消