twisted 解析页面失败

Helo gays:

     I am a IT Diaosi from china, you can call me Kevin.

     I found a strange behaviour about twisted when I fetch some url. It always report error about response parsing.

   It’s so strange that I used tcpdump to know what happened, as a result, I found that some website return HTTP/1.1 302 , so I guess maybe it was caused by having no FOUND?

   Yep, I guess it. I found this in web/_newclient.py:

   def statusReceived(self, status):
          parts = status.split(' ', 2)
          if 3 != len(parts):
                 raise ParseError("wrong number of parts", status)
          ……

   But those url can be accessed rightly by curl.

   Is it a bug?

   I changed the code like this finally:

          def statusReceived(self, status):
                 parts = status.split(' ', 2)
                 if len_parts < 2:
                        raise ParseError("wrong number of parts", status)
                        elif len_parts == 2:
                                 parts.append('NULL')
                        else:
                                 parts[2] = ‘-‘.join(parts[2:])

     except your replay…..

你可能感兴趣的:(http,response,status,twisted)