curl post with authentication

453 views
Skip to first unread message

thodoris

unread,
Oct 28, 2011, 7:33:59 AM10/28/11
to web2py-users
Hi,

I have this simple configuration:

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

@auth.requires_login()
def upload():
db.files.id.default = request.args(0)
form = crud.create(db.files)
return dict(form=form)

If i remove authentication from upload() i can upload a file using
curl. But i would like apply the authentication restriction. So i
register a user with username: te...@nowhere.com and password:1111 and
i try the following command

curl --verbose -u te...@nowhere.com:1111 -F "file=@/home/thodoris/
Downloads/test.rtp" -F "_formname=files/None" http://127.0.0.1:8000/test/default/upload

and i get the following error message:

* About to connect() to 127.0.0.1 port 8000 (#0)
* Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
* Server auth using Basic with user 'te...@nowhere.com'
> 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: 127.0.0.1:8000
> Accept: */*
> Content-Length: 3187083
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------69a14296aa8c
>
< HTTP/1.1 100 Continue
< HTTP/1.1 303 SEE OTHER
< Set-Cookie: session_id_test=127.0.0.1-0054c564-830d-4fe4-
ae3d-924a1ba931b8; Path=/
< Content-Type: text/html; charset=UTF-8
* Avoided giant realloc for header (max is 102400)!
* Closing connection #0
curl: (27) Avoided giant realloc for header (max is 102400)!

Could anyone help me understand what the problem is and how to solve
it?

I have also tried setting

auth.settings.allow_basic_login=True in the models but still the same.

szimszon

unread,
Oct 28, 2011, 8:27:53 AM10/28/11
to web...@googlegroups.com

thodoris

unread,
Oct 29, 2011, 1:42:34 PM10/29/11
to web2py-users
Yes it is related and there is a patch for this. More details on the
above link.

Massimo Di Pierro

unread,
Oct 29, 2011, 7:35:38 PM10/29/11
to web2py-users
I am lost. Can you summarize problem and email me the patch?

szimszon

unread,
Oct 30, 2011, 5:41:43 AM10/30/11
to web...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages