Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error method parsed when more data append request buffer #70

Open
rainhard opened this issue Apr 18, 2017 · 2 comments
Open

Error method parsed when more data append request buffer #70

rainhard opened this issue Apr 18, 2017 · 2 comments

Comments

@rainhard
Copy link

rainhard commented Apr 18, 2017

I made a demo

try:
    from http_parser.parser import HttpParser
except ImportError:
    from http_parser.pyparser import HttpParser

req = "GET / HTTP/1.1\r\nHost: www.xxx.com\r\n\r\n"
resp = "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\n1234"

data = req
p = HttpParser()
nparsed = p.execute(data, len(data))
print p.get_method(), nparsed, len(data)
# Got: GET 37 37

data = req + resp
p = HttpParser()
nparsed = p.execute(data, len(data))
print p.get_method(), nparsed, len(data)
# Got: HEAD 38 79
# pyparser Got: GET 79 79

# expected: GET 37 79
@benoitc
Copy link
Owner

benoitc commented Apr 21, 2017

i will have a look. thanks!

@UH4CK3R
Copy link

UH4CK3R commented Jan 3, 2025

I solve this issue in this way

import unicodedata

packet = "{Raw Packet String}"
packet = unicodedata.normalize('NFC', packet)

p = HttpParser()
nparsed = p.execute(data, len(packet))

print(p.get_method())

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

No branches or pull requests

3 participants