tominsam / PythonDaap

DAAP client library implemented in Python
http://jerakeen.org/code/pythondaap/
GNU Lesser General Public License v2.1
11 stars 4 forks source link

Missing User-Agent #1

Closed decibyte closed 12 years ago

decibyte commented 12 years ago

When I try to connect to a share served by forked-daapd (on Ubuntu), itshell.py dies.

Output from itshell.py:

Connecting to 'localhost':3689
2011-12-05 11:17:50,494 DEBUG getting /content-codes
2011-12-05 11:17:54,691 DEBUG gunzipping data
2011-12-05 11:17:54,692 DEBUG expanded from 1770 bytes to 7045 bytes
2011-12-05 11:17:54,697 DEBUG getting /server-info
2011-12-05 11:17:59,267 DEBUG gunzipping data
2011-12-05 11:17:59,268 DEBUG expanded from 128 bytes to 175 bytes
2011-12-05 11:17:59,268 DEBUG getting /login
Traceback (most recent call last):
  File "itshell.py", line 193, in <module>
    shell.cmdloop()
  File "/usr/lib/python2.7/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python2.7/cmd.py", line 219, in onecmd
    return func(arg)
  File "itshell.py", line 55, in do_connect
    self.session = client.login()
  File "/usr/lib/pymodules/python2.7/daap.py", line 471, in login
    response = self.request("/login")
  File "/usr/lib/pymodules/python2.7/daap.py", line 435, in request
    raise DAAPError('DAAPClient: %s: Authentication failure'%r)
daap.DAAPError: DAAPClient: /login: Authentication failure

And from forked-daapd.log (on the server):

[2011-12-05 11:23:09]     daap: DAAP request: /content-codes
[2011-12-05 11:23:09]     daap: DAAP request: /server-info
[2011-12-05 11:23:09]     daap: DAAP request: /login
[2011-12-05 11:23:09]     daap: No User-Agent header, rejecting login request

It seems forked-daapd expects a User-Agent header to be present. I don't know if this header is part of any DAAP specification, but I guess it's fairly easy to add a User-Agent header to please forked-daapd (I might as well do it myself if I find the time).

decibyte commented 12 years ago

Okay, I just made a dirty test, adding this line to daap.py in DAAPClient._get_response() where the headers are set (around line 380 in the version distributed with Ubuntu 11.10):

'User-Agent': 'PythonDaap',

Now everything seems to work. I'll fork and push something later today when I get the time.

tominsam commented 12 years ago

there is no daap specification, it's all reverse-engineered. :-)

I've added one to the client:

https://github.com/tominsam/PythonDaap/commit/a52ee05471be295e66f350f2a0554f4f8fd1d52b

entirely untested, as I'm at work and don't have any daap servers any more. But it might work for you..

On 5 Dec 2011, at 10:27, Mikkel Munch Mortensen wrote:

When I try to connect to a share served by forked-daapd (on Ubuntu), itshell.py dies.

Output from itshell.py:

Connecting to 'localhost':3689 2011-12-05 11:17:50,494 DEBUG getting /content-codes 2011-12-05 11:17:54,691 DEBUG gunzipping data 2011-12-05 11:17:54,692 DEBUG expanded from 1770 bytes to 7045 bytes 2011-12-05 11:17:54,697 DEBUG getting /server-info 2011-12-05 11:17:59,267 DEBUG gunzipping data 2011-12-05 11:17:59,268 DEBUG expanded from 128 bytes to 175 bytes 2011-12-05 11:17:59,268 DEBUG getting /login Traceback (most recent call last): File "itshell.py", line 193, in shell.cmdloop() File "/usr/lib/python2.7/cmd.py", line 142, in cmdloop stop = self.onecmd(line) File "/usr/lib/python2.7/cmd.py", line 219, in onecmd return func(arg) File "itshell.py", line 55, in do_connect self.session = client.login() File "/usr/lib/pymodules/python2.7/daap.py", line 471, in login response = self.request("/login") File "/usr/lib/pymodules/python2.7/daap.py", line 435, in request raise DAAPError('DAAPClient: %s: Authentication failure'%r) daap.DAAPError: DAAPClient: /login: Authentication failure

And from forked-daapd.log (on the server):

[2011-12-05 11:23:09] daap: DAAP request: /content-codes [2011-12-05 11:23:09] daap: DAAP request: /server-info [2011-12-05 11:23:09] daap: DAAP request: /login [2011-12-05 11:23:09] daap: No User-Agent header, rejecting login request

It seems forked-daapd expects a User-Agent header to be present. I don't know if this header is part of any DAAP specification, but I guess it's fairly easy to add a User-Agent header to please forked-daapd (I might as well do it myself if I find the time).


Reply to this email directly or view it on GitHub: https://github.com/tominsam/PythonDaap/issues/1

decibyte commented 12 years ago

Wow, that was quick. Thanks!

Regarding the specification (or lack of one), I thought the omission might be because iTunes shares would refuse clients without a proper "iTunes ..." user agent (you'd never know when it's up to Apple, but then again -- no user agent isn't "iTunes ..." either). But if it's just an omission because it wasn't necessary until now, that's great.

Now I'll try to find out how to get the change into Ubuntu (and Debian?) repositories. But that's another story.

Thanks again. And feel tree to close this issue if you like.

tominsam commented 12 years ago

Well, given that the python client can't talk to any versions of itunes released in the last 5 years, I'm not too bothered about that...

Can't help you with the debianing, I'm afraid. Someone else did that.