Ruby Net :: HTTP - stop auto escaping of quotes?

I have the following code:

    http = Net::HTTP.new("www.something.com", 80)
    http.set_debug_output($stdout)
    http.post("/blah", "something", {'random-parameter' => 'value1="something",value2="somethingelse"'})

Then, when I read the output from stdout, it looks like this:

<- "POST /blah HTTP/1.1\r\nAccept: */*\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nrandom-parameter: value1=\"something\",value2=\"somethingelse\"\r\nContent-Length: 9\r\nHost: www.something.com\r\n\r\n"
<- "something"

the quotes will be escaped. The problem is that slashes seem to be sent to the server, which is not like it. I get an error

Unknown value for random-parameter in header: {value1=\\\"something\\\"value2=\\\"somethingelse\\\"}

So my question is: is there a way to tell Net :: HTTP not to insert these slashes or to cut them out before sending the header?

Explanations:

I am using Ruby 1.8.7 with Rails 2.0.2.

I think it might be Rails that eludes characters, but I'm not sure how to stop it.

+5
source share
2 answers

, ? Net:: HTTP . , , , netcat (nc):

1:

> nc -v -l -p 2323

2 ( irb):

> http = Net::HTTP.new("localhost", 2323)
> http.post("/blah", "something", {'random-parameter' => ... )

( 1):

listening on [any] 2323 ...
connect to [127.0.0.1] from localhost [127.0.0.1] 37598
POST /blah HTTP/1.1
Connection: close
Accept: */*
Random-Parameter: value1="something",value2="somethingelse"
Content-Type: application/x-www-form-urlencoded
Content-Length: 9
Host: localhost:2323

something

, ( , ) - HTTP:

> http.post("/blah", "something", {
    'random-parameter' => 'value1="something"; value2="somethingelse"' })

Rails, , 1 =... .., , , ;; 'not', '.

, . , , , (?) URL-, param1 = foo & param2 = bar, x-www-form-urlencoded .

. :
http://www.rubyinside.com/nethttp-cheat-sheet-2940.html

+2

, / " ", .

, , - , , ?

0

All Articles