Seite 1 von 1
HTTPlib.IncompleteRead Exception
Verfasst: Sonntag 19. September 2004, 21:27
von rayo
Hi
Ich downloade mit der HTTP-Lib Dateien herunter. Jedoch kommt ab und zu die Exception IncompleteRead. Woher kommt die? Hab nichts darüber in der Doku gefunden
Code: Alles auswählen
conn = httplib.HTTPConnection("files.xyz.de")
conn.request('GET',url,None,{'Referrer':"/index.php"})
r1 = conn.getresponse()
data = r1.read()
conn.close()
gruss
Verfasst: Sonntag 19. September 2004, 21:53
von Dookie
Hi rayo,
ich würd mal die Rückmeldung (response) testen.
Code: Alles auswählen
conn = httplib.HTTPConnection("files.xyz.de")
conn.request('GET',url,None,{'Referrer':"/index.php"})
r1 = conn.getresponse()
if r1.reason == "OK":
data = r1.read()
else:
print "Fehler: %s" % r1.reason
conn.close()
Gruß
Dookie
Verfasst: Sonntag 19. September 2004, 22:11
von rayo
Hi
Danke für die Antwort. Leider ist reason und status immer OK oder 200.
Sind alles Zip-Dateien, aber daran sollte es ja nicht liegen.
Hat noch jemand eine Idee?
Gruss
*edit* Hab noch einen Text in einer Doku gefunden, vielleicht hilft das was, mir sagt dass nicht viel:
_safe_read(self, amt)
Read the number of bytes requested, compensating for partial reads.
Normally, we have a blocking socket, but a read() can be interrupted
by a signal (resulting in a partial read).
Note that we cannot distinguish between EOF and an interrupt when zero
bytes have been read. IncompleteRead() will be raised in this
situation.
This function should be used when <amt> bytes "should" be present for
reading. If the bytes are truly not available (due to EOF), then the
IncompleteRead exception can be used to detect the problem.
Verfasst: Sonntag 19. September 2004, 22:38
von Dookie
aha, soviel ich da rauslese, tritt die Exception auf, um anzuzeigen, daß bei der Übertragung der Daten eine Unterbrechung aufgetreten ist, bzw. nicht die geforderte Anzahl an Bytes gelesen werden konnte.
Gruß
Dookie
Verfasst: Sonntag 19. September 2004, 23:22
von rayo
Hi
Dann muss ich wohl davon ausgehen dass beim server was falsch ist.
Danke