On Jan 14, 2008 11:34 AM, Tilmann Singer <til@...> wrote:
> * Till <klimpong@...> [20080113 15:24]:
> > my request is versus https://sandbox.plazes.com/sessions.xml
> >
> > This is what I get in response:
> > <html>
> > <head><title>411 Length Required</title></head>
> > <body bgcolor="white">
> > <center><h1>411 Length Required</h1></center>
> > <hr><center>nginx/0.5.35</center>
> > </body>
> > </html>
> >
> > Btw, it works when I issue the same via curl - I just have no idea
> > what I need to supply in terms of "Length" here.
> >
> > Obviously the request is a "POST" and I am not sending a "body" along.
> > I tried to send an empty body ('') - but that didn't help either. Is
> > this anything you can do about this? I'm not too up to date on HTTP
> > spec, but if Content-Length is absolutely required and not set - then
> > I guess it's a bug somewhere else.
>
> Your client needs to include this http header in the request:
>
> Content-Length: 0
>
> According to the http spec this header SHOULD be included in every
> POST request - not sure what to do if the body is empty. It doesn't
> make too much sense that rails on the server side is enforcing the
> length requirement in that case in my opinion, but maybe there is a
> good reason for this.
Yeah, if it's spec - no problem. I got it working with Content-Length 0 already.
Got a link handy from the spec?
Thanks,
Till
> If you can't easily make your client library include the header, a
> workaround may be to send some whitespace in the body, that would be
> ignored by plazes. For example:
>
> tils@tilsbox:~/lunch$ curl -v -u joe:secret -X POST
http://sandbox.plazes.com/sessions.xml -d ' '
> * About to connect() to sandbox.plazes.com port 80 (#0)
> * Trying 78.46.49.103... connected
> * Connected to sandbox.plazes.com (78.46.49.103) port 80 (#0)
> * Server auth using Basic with user 'til'
> > POST /sessions.xml HTTP/1.1
> > Authorization: Basic dGlsOmlnZ3U=
> > User-Agent: curl/7.16.4 (i486-pc-linux-gnu) libcurl/7.16.4
> > OpenSSL/0.9.8e zlib/1.2.3.3 libidn/1.0
> > Host: sandbox.plazes.com
> > Accept: */*
> > Content-Length: 1
> > Content-Type: application/x-www-form-urlencoded
> >
> < HTTP/1.1 200 OK
> < Server: nginx/0.5.35
> < Date: Mon, 14 Jan 2008 10:30:21 GMT
> < Content-Type: application/xml; charset=utf-8
> < Connection: keep-alive
> < Set-Cookie: _session_id=c157a5e7404fbc7437d0180572ab1168;
> domain=.plazes.com; path=/
> < Status: 200 OK
> < Location:
> http://sandbox.plazes.com/sessions/c157a5e7404fbc7437d0180572ab1168
> < X-Runtime: 0.00678
> < ETag: "7429055448796d66cd6881524b012eba"
> < Cache-Control: private
> < Content-Length: 168
> < Expires: Wed, 25 Sep 1974 02:00:00 GMT
> <
> <?xml version="1.0" encoding="UTF-8"?>
> <session>
> <created_at type="datetime">2008-01-14T10:30:21Z</created_at>
> <id>c157a5e7404fbc7437d0180572ab1168</id>
> </session>
>
>
> Til