I have the following configuration

auth.settings.allow_basic_login=True

db.define_table( 'files',
    Field('file','upload'))

@auth.requires_login()
def upload():
    form = crud.create(db.files)
    return dict(form=form)

and i applied the PATCH mentioned here 
https://groups.google.com/forum/#!topic/web2py/CDHOUqtICn8

I executed the setup-web2py-ubuntu.sh script and the everything works
ok from the webpage.

What i want to do is upload a file using curl.

If i don't use authentication, using the following command the file is
uploaded:

curl -F file=@/home/thodoris/Documents/test.jpg.rtp -F _formname=files/
None  http://192.168.1.75/test/default/upload

If i use authentication and use the command

curl --verbose -u [email protected]:1111 -F file=@/home/thodoris/
Documents/test.jpg.rtp -F _formname=files/None  
http://192.168.1.75/test/default/upload

i get the following error:

* About to connect() to 192.168.1.75 port 80 (#0)
*   Trying 192.168.1.75... connected
* Connected to 192.168.1.75 (192.168.1.75) port 80 (#0)
* Server auth using Basic with user '[email protected]'
> POST /test/default/upload HTTP/1.1
> Authorization: Basic dGVzdEBub3doZXJlLmNvbToxMTEx
> User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o 
> zlib/1.2.3.4 libidn/1.18
> Host: 192.168.1.75
> Accept: */*
> Content-Length: 60669
> Expect: 100-continue
> Content-Type: multipart/form-data; 
> boundary=----------------------------dd827f333b42
>
< HTTP/1.1 100 Continue
< HTTP/1.1 500 Internal Server Error
< Date: Thu, 03 Nov 2011 11:24:32 GMT
< Server: Apache/2.2.17 (Ubuntu)
< Vary: Accept-Encoding
< Content-Length: 592
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>303 SEE OTHER</title>
</head><body>
<h1>SEE OTHER</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 [no address given] and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.2.17 (Ubuntu) Server at 192.168.1.75 Port 80</
address>
</body></html>
* Closing connection #0

And the error in apache log is:

[Thu Nov 03 12:24:32 2011] [error] [client 192.168.1.75] malformed
header from script. Bad header=x98%255Cxa0%255CxdaKk4Ht%255Cx:
wsgihandler.py

When i use the internal server from web2py and not Apache i use the
exact same configuration and it WORKS. Could someone give me some
advice of how to solve this???

Reply via email to