Skip to content
This repository was archived by the owner on Aug 8, 2024. It is now read-only.
This repository was archived by the owner on Aug 8, 2024. It is now read-only.

Parser fails to get HTTP version for HTTP 2 protocol #22

Description

@jsalort

The parser works fine with HTTP/1.1 but fails with HTTP/2 that appears in Apache log with Protocols h2.

Simple example (lineB is an actual output in the Apache server log file, lineA is used to demonstrate that it works when replacing HTTP/2 by HTTP/1.1).

from apache_log_parser import make_parser
from pprint import pprint

lineA = '''137.226.113.25 - - [31/Dec/2017:03:14:19 +0100] "GET / HTTP/1.1" 200 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"'''
lineB = '''137.226.113.25 - - [31/Dec/2017:03:14:19 +0100] "GET / HTTP/2" 200 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"'''

line_parser = make_parser("%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"")

dataA = line_parser(lineA)
pprint(dataA)
dataB = line_parser(lineB)
pprint(dataB)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions