Giter Site home page Giter Site logo

Comments (2)

Querela avatar Querela commented on May 25, 2024

Ok. I found the record.http_headers.status_line attribute but the .status_code does not work?
Same example as above:

>>> record.headers.status_code  # expected
>>> record.headers.status_line
'WARC/1.0'
>>> record.http_headers.status_code  # unexpected
>>> record.http_headers.status_line
'HTTP/1.1 301 Moved Permanently'

I believe the following line should be changed:

s = self._status_line.split(b' ')

# split at most 2 times, so the possible third part contains the whole reason phrase
s = self._status_line.split(b' ', 2)

It seems as if Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF does not mean the SP can't appear in then Reason-Phrase, as is later specified with Reason-Phrase = *<TEXT, excluding CR, LF> in section 6.1.1.

from chatnoir-resiliparse.

Querela avatar Querela commented on May 25, 2024

I think I oversaw something. And this might have already existed before the updated status code parsing:

>>> record.http_headers.status_line
'HTTP/1.1 200 OK'
>>> record.http_headers.status_code
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "fastwarc/warc.pyx", line 208, in fastwarc.warc.WarcHeaderMap.status_code.__get__
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
>>>

should be changed to int(s[1]), as s is still a list.
I'm somewhat unsure how this came to be, as the parsing of the status line should be correct but I would still not have gotten the correct status code integer, so my pull request was also only half-finished.

from chatnoir-resiliparse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.