jwodder / apachelogs

Parse Apache access logs
MIT License
25 stars 2 forks source link

Support all possible three-digit HTTP status codes #2

Closed chosak closed 4 years ago

chosak commented 4 years ago

Currently the %s status code directive is parsed as a uinteger, which prevents parsing of unofficial status codes that begin with 0, and allows codes with more than three digits.

Per IETF RFC 7231, section 6:

[t]he status code element is a three-digit integer code

Although there aren't any official codes starting with 0, various servers seem to use 000 if an HTTP connection is closed before the response can be fully returned: Akamai, Cloudfront (page 271), old versions of Nginx.

This commit creates a new type called status_code, which is explicitly a three-digit integer.

codecov[bot] commented 4 years ago

Codecov Report

Merging #2 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master        #2   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          362       363    +1     
  Branches        99        99           
=========================================
+ Hits           362       363    +1     
Impacted Files Coverage Δ
apachelogs/directives.py 100.00% <ø> (ø)
apachelogs/util.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7ee86af...fbb090e. Read the comment docs.

jwodder commented 4 years ago

Thank you for the patch! This has now been released in version 0.6.0.