Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#5262 defect closed duplicate (duplicate)

twisted.web.client.HTTPClient breaks on bare LF-terminated header fields

Reported by: jacky ma Owned by:
Priority: normal Milestone:
Component: web Keywords:
Cc: jknight, ivank Branch:

Description (last modified by Jean-Paul Calderone)

my english is poor,please look at following:

        Traceback (most recent call last):
          File "/usr/local/python2.7/lib/python2.7/site-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/python/", line 84, in callWithLogger
            return callWithContext({"system": lp}, func, *args, **kw)
          File "/usr/local/python2.7/lib/python2.7/site-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/python/", line 69, in callWithContext
            return{ILogContext: newCtx}, func, *args, **kw)
          File "/usr/local/python2.7/lib/python2.7/site-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/python/", line 118, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/local/python2.7/lib/python2.7/site-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/python/", line 81, in callWithContext
            return func(*args,**kw)
        --- <exception caught here> ---
          File "/usr/local/python2.7/lib/python2.7/site-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/", line 146, in _doReadOrWrite
            why = getattr(selectable, method)()
          File "/usr/local/python2.7/lib/python2.7/site-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/", line 460, in doRead
            rval = self.protocol.dataReceived(data)
          File "/usr/local/python2.7/lib/python2.7/site-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/protocols/", line 564, in dataReceived
            why = self.lineReceived(line)
          File "/usr/local/python2.7/lib/python2.7/site-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/web/", line 448, in lineReceived
          File "/usr/local/python2.7/lib/python2.7/site-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/web/", line 409, in extractHeader
            self.length = int(val)
        exceptions.ValueError: invalid literal for int() with base 10: '831\nPragma: no-cache'

Change History (3)

comment:1 Changed 7 years ago by DefaultCC Plugin

Cc: jknight added

comment:2 Changed 7 years ago by ivank

Cc: ivank added
Milestone: Python-2.7
Resolution: duplicate
Status: newclosed
Summary: exceptions.ValueError: invalid literal for int() with base 10: '831\nPragma: no-cache'twisted.web.client.HTTPClient breaks on bare LF-terminated header fields

You're getting a response from a broken server that sends \n instead of the correct line terminator \r\n. If you use the new HTTP client twisted.web.client.Agent [1] in a recent version of Twisted, it'll be able to handle an HTTP response that uses n.


This is a duplicate of #2842

comment:3 Changed 7 years ago by Jean-Paul Calderone

Description: modified (diff)

Fixing description markup, too.

Note: See TracTickets for help on using tickets.