iPhone use NSURLRequest, NSURLConnection to POST data to rails site.
Request is the next:
POST / HTTP/1.1
User-Agent: CFNetwork/330
Content-Type: multipart/form-data;
boundary=------580a9a040b19fc6621c596d9c40097f7
Accept: */*
Accept-Language: ru
Accept-Encoding: gzip, deflate
Content-Length: 295
Connection: keep-alive
Host: 192.168.0.20:8888
Well, you can contribute a failing test and a patch to Rails yourself. This wouldn’t be the first time Rails fixed a badly implemented HTTP spec by Apple.
I ran into the same problem because I probably found the same example
you did, which was built for use with Perl, not Rails. Perl is
apparently more tolerent of simple formatting errors, which is not
surprising considering Larry Wall's philosophy.The example contains a
line similar to this:
[ body appendData:[[NSString stringWithFormat:@"\r\n--%@\r
\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
It turns out that is wrong. The initial \r\n should not be there, so
you should have:
[ body appendData:[[NSString stringWithFormat:@"--%@\r\n",boundary]
dataUsingEncoding:NSUTF8StringEncoding]];
Once I made that change, everything worked perfectly.