Streaming Data Error in .read() (HTTP/ICY) Possible Bug?

M

MyHaz

I playing around with streaming shoutcast mp3s.

Here is some sample code:

-----------------------
import httplib

############
# Put together the headers
headers = {"Icy-MetaData":"1"}

con = httplib.HTTPConnection('64.142.8.154', 8000)
con.request("GET", "/")
stream = con.getresponse()
print stream.status,stream.reason
print stream.read()
-----------------------

For which i get error:

bash-2.05b$ ./woxy_saver.py
200
Traceback (most recent call last):
File "./woxy_saver.py", line 21, in ?
print stream.read()
File "C:\python24\lib\httplib.py", line 463, in read
s = self._safe_read(self.length)
File "C:\python24\lib\httplib.py", line 545, in _safe_read
chunk = self.fp.read(amt)
File "C:\python24\lib\httplib.py", line 1273, in read
return s + self._file.read(amt - len(s))
TypeError: unsupported operand type(s) for -: 'str' and 'int'
bash-2.05b$

It seems somehow amt is turning into a str.

Is this a bug in httplib.py or there something wrong with my code?


Cheers
- Haz
 
G

gideondominick

I should purhaps mention that i am basically trying to translate this.

nc ~= telnet

#!/bin/sh

nc sc1.liquidviewer.com 9012 <<EOF
GET / HTTP/1.0
Icy-MetaData:1


EOF
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top