BadStatusLine:

Discussion in 'Python' started by noelob, Sep 22, 2008.

  1. noelob

    noelob Guest

    Hi All,

    During performance testing of my web application, I occasionally get a
    BadStatusLine exception from httplib. Reading
    http://docs.python.org/lib/module-httplib.html#l2h-4021 tells me that
    it's "Raised if a server responds with a HTTP status code that we
    don't understand." Is there a way to find what the actual status code
    returned was? I.e. the value that caused the exception to be thrown?
    Under what circumstances is a BadStatusLine normally thrown? (e.g.
    data corruption?)

    I'm quite new to python, but not to programming. Apologies if this is
    a silly question ;)

    Thanks,
    Noel
     
    noelob, Sep 22, 2008
    #1
    1. Advertising

  2. noelob a écrit :
    > Hi All,
    >
    > During performance testing of my web application, I occasionally get a
    > BadStatusLine exception from httplib. Reading
    > http://docs.python.org/lib/module-httplib.html#l2h-4021 tells me that
    > it's "Raised if a server responds with a HTTP status code that we
    > don't understand." Is there a way to find what the actual status code
    > returned was? I.e. the value that caused the exception to be thrown?
    > Under what circumstances is a BadStatusLine normally thrown? (e.g.
    > data corruption?)


    httplib is a pure-python module, so nothing prevents you from reading
    the source code to get more accurate informations. It appears that this
    exception is raised when:

    - the status line is empty
    - the 'strict' flag is on and the status line didn't start with 'HTTP/'
    - the 'status' part of the status line is not convertible to an int
    - the status code ('status' part of the status line, converted to an
    int) is lower than 100 or higher than 999

    NB: I may have missed something...

    In all cases, the offending status line is accessible as either .line
    and .args attribute of the exception.

    > I'm quite new to python, but not to programming. Apologies if this is
    > a silly question ;)


    Well... Not a silly question IMHO, but surely one you could have solved
    by yourself. It only requires two commands on an average posix system:
    - cd /your/python/install/lib/
    - grep -A5 -B5 BadStatusLine httplib.py

    HTH
     
    Bruno Desthuilliers, Sep 22, 2008
    #2
    1. Advertising

  3. noelob wrote:

    > Hi All,
    >
    > During performance testing of my web application, I occasionally get a
    > BadStatusLine exception from httplib. Reading
    > http://docs.python.org/lib/module-httplib.html#l2h-4021 tells me that
    > it's "Raised if a server responds with a HTTP status code that we
    > don't understand." Is there a way to find what the actual status code
    > returned was? I.e. the value that caused the exception to be thrown?
    > Under what circumstances is a BadStatusLine normally thrown? (e.g.
    > data corruption?)
    >
    > I'm quite new to python, but not to programming. Apologies if this is
    > a silly question ;)


    Bruno gave some advice already. I can only add that for the general task of
    inspecting HTTP-traffic, tools such as axis-tcpmon or wireshark are useful.
    There you can see what happens on the protocol level.

    Diez
     
    Diez B. Roggisch, Sep 22, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim

    BadStatusLine error

    Jim, May 28, 2008, in forum: Python
    Replies:
    2
    Views:
    822
  2. ak
    Replies:
    7
    Views:
    5,500
  3. up2date.cyborg

    urllib2.urlopen+BadStatusLine+https

    up2date.cyborg, May 12, 2011, in forum: Python
    Replies:
    0
    Views:
    391
    up2date.cyborg
    May 12, 2011
Loading...

Share This Page