well, i was looking at it, and i see that the 'body' function is basically 
this:


self._body = copystream_progress(self)
            except IOError:
                raise HTTP(400, "Bad Request - HTTP body is incomplete")

and looking at copystream_progress, the only path leading to a 400 error 
there is a missing content_length header. 

if all that looks good, make sure your filenames are sent in utf-8

On Friday, April 4, 2014 9:36:38 AM UTC-7, ayresrichard wrote:
>
> It is a multipart yes. I was able to use request.body.read() to read the 
> requests' body in other platforms. It looks ok, and everything works. I 
> even changed from using FormData in javascript to writing my custom body 
> and so on. It all works fine except in iOS. There seems to be some kind of 
> problem reading the body. And I can't even know what is there, since the 
> server raises the 400 BAD REQ whenever I try to access it....
>
> I don't understand very well how xmlhttprequest works and so on, I am only 
> sending text right now, would I be able to solve this problem by changing 
> the content-type header? I tried text/plain but that didn't work as 
> well.... 
>
> On Friday, March 28, 2014 2:03:31 AM UTC, Massimo Di Pierro wrote:
>>
>> Is this a normal multipart post request? If not, perhaps you should use 
>> request.body.read() and log what is in there.
>>
>>
>> On Thursday, 27 March 2014 07:48:39 UTC-5, ayresrichard wrote:
>>>
>>>
>>> I am developing a web browser application where the user must upload a 
>>> image file to a web2py server.
>>>
>>> I am using the traditional way for file input, which, in the iPad, gives 
>>> the option to either upload an existing picture or take a new one from the 
>>> camera.
>>>
>>> var url = "http://please-help-me.com";;          
>>> var file = document.getElementById("file").files[0];
>>>
>>>
>>> var fd2 = new FormData();
>>> fd2.append("upload", file);
>>> fd2.append("id", 123);  
>>>
>>>
>>> var reader = new XMLHttpRequest();
>>> reader.open('post',url, true); 
>>> reader.onreadystatechange = function() {
>>>     console.log("Status:" + reader.status);
>>> }
>>> reader.send(fd2);
>>>
>>>
>>> This works fine in the desktop browsers, Android browser, but not in the 
>>> iPad, where it occasionally gives a 400 Bad Request Error. It doesn't 
>>> return the error every time. Just sporadically.
>>>
>>> Web2py returns this error message:
>>>
>>>   ERROR:Rocket.Errors.Thread-20:Traceback (most recent call last):
>>>   File "/home/mdipierro/make_web2py/web2py/gluon/rocket.py", line 1337, 
>>> in run
>>>   File "/home/mdipierro/make_web2py/web2py/gluon/rocket.py", line 1838, 
>>> in run_a
>>> pp
>>>   File "/home/mdipierro/make_web2py/web2py/gluon/main.py", line 651, 
>>> inapp_with
>>> _logging
>>>   File "/home/mdipierro/make_web2py/web2py/gluon/main.py", line 532, 
>>> inwsgibase
>>>   File "/home/mdipierro/make_web2py/web2py/gluon/globals.py", line 252, 
>>> in body
>>> HTTP: 400 BAD REQUEST
>>>
>>>
>>> Searching in the code, it appears the content of the post message is not 
>>> valid and the web2py body function has trouble reading it. The error rises 
>>> when I try to read the request.post_vars data
>>>
>>> I've tested the code without sending the image (and only sending other 
>>> data) and it seems to be working every time. Is there a specific parameter 
>>> I should add to the request? Why does it work sometimes, but not all the 
>>> time?
>>>
>>> Thanks
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to