Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been trying to login in the pyload through the web api, but wget is not saving the cookies and I don't understand why.

I'm using the following command:

wget --delete-after --keep-session-cookies --save-cookies=my_cookies.txt --post-data="username=USERNAME&password=PASSWORD" http://localhost:8000/api/login

But the content of my_cookies.txt is:

# HTTP cookie file.
# Generated by Wget on 2012-06-23 22:31:33.
# Edit at your own risk.

When I run the same command but in debug mode I get the following output that includes the set cookie in the header response:

DEBUG output created by Wget 1.10.2 (Red Hat modified) on linux-gnueabi.

--22:31:11--  http://localhost:8000/api/login
Resolving localhost... 127.0.0.1
Caching localhost => 127.0.0.1
Connecting to localhost|127.0.0.1|:8000... connected.
Created socket 3.
Releasing 0x000504d0 (new refcount 1).

---request begin---
POST /api/login HTTP/1.0
User-Agent: Wget/1.10.2 (Red Hat modified)
Accept: */*
Host: localhost:8000
Connection: Keep-Alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 32

---request end---
[POST data: username=USERNAME&password=PASSWORD]
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 200 OK
Content-Length: 34
Content-Type: application/json
Cache-Control: no-cache, must-revalidate
Set-cookie:  beaker.session.id=405390ddc809efed54820638c95d7997; expires=Tue, 19-Jan-2038 04:14:07 GMT; Path=/
Connection: Keep-Alive
Date: Sat, 23 Jun 2012 21:31:11 GMT
Server: CherryPy/3.1.2 WSGI Server

---response end---
200 OK
hs->local_file is: login (not existing)
Registered socket 3 for persistent reuse.
TEXTHTML is on.
Length: 34 [application/json]
Saving to: `login'

100%[=======================================>] 34          --.-K/s   in 0s

22:31:11 (1.28 MB/s) - `login' saved [34/34]

Removing file due to --delete-after in main():
Removing login.
Saving cookies to my_cookies.txt.
Done saving cookies.

Can anyone tell me what am I doing wrong?

Thanks in advance!

share
add comment

2 Answers

up vote 0 down vote accepted

Considering you're still using version 1.10.2, you might be experiencing a bug which was fixed in version 1.12, August of 2009. You really should consider upgrading, especially since the newest version is 1.13.4, released near September, 2011.

Anyways... the bug in question is thus: bugGNU Wget - Bugs: bug #26775, Save cookies from non-200 responses, which involves wget NOT saving cookies when it receives a non-200 return error code.

It's quite possible your non-debug requests are being cached or something, or involve a 302-redirect... all of which cause the request to return a non 200 return code. Your debug output DOES show 200-OK codes... did you use the exact same command-line to perform the debug request as when doing the 'normal' request?

share
    
I've been trying to update using optware but with no success. The debug I tried I just added the switch -d to the command I posted. I guess I'll look around how to upgrade wget and I'll try no-cache in the command. –  TrymBeast Jun 24 '12 at 12:52
    
Homepage & sourcecode found at: gnu.org/software/wget –  lornix Jun 24 '12 at 13:45
add comment

Use --keep-session-cookies as session cookies are not saved by default

share
add comment

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .