3
# Copyright (c) 2007 Tomas Kramar (kramar.tomas@gmail.com), Jonathan Rauprich (joni@noplu.de)
5
# This library is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU Lesser General Public
7
# License as published by the Free Software Foundation; either
8
# version 2 of the License, or (at your option) any later version.
10
# This library is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
# Lesser General Public License for more details.
15
# You should have received a copy of the GNU Lesser General Public
16
# License along with this library; if not, write to the
17
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
# Boston, MA 02111-1307, USA.
23
import lastfmexception
31
def __init__(self, host, port):
38
def readline(self, s):
54
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
55
s.connect((self.host, self.port))
56
s.send("GET " + url + " HTTP/1.0\r\n")
57
s.send("Host: " + self.host + "\r\n")
60
line = self.readline(s)
61
self.status = string.rstrip(line)
65
line = self.readline(s)
70
tmp = string.split(line, ": ")
71
self.headers[tmp[0]] = string.rstrip(tmp[1])
75
line = self.readline(s)
78
self.response = self.response + line
81
#print "Unexpected error: ", sys.exc_info()[0]
82
#print "Unable to contact last.fm"
83
raise lastfmexception.LastFmException(sys.exc_info()[0])