-
Notifications
You must be signed in to change notification settings - Fork 270
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
Solve #164, make http.py return ordered headers. #188
Conversation
We could have, if ordereddict was a necessity. However:
How about doing this instead: |
We could pull https://pypi.python.org/pypi/ordereddict as a dependency. One of the nice things about dpkt is we have no requirements outside the standard library, seems a shame to add a dependency just for this small thing. |
Just saw Kiran's comment, yeah that's the right thing to do. Also +10 for automated CI :) |
@@ -4,11 +4,12 @@ | |||
|
|||
import cStringIO | |||
import dpkt | |||
import collections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try:
from collections import OrderedDict
except ImportError:
OrderedDict = dict
Guys, is it really usefull feature? If we use ordered dict we would lose in speed of execution (and I think even in seconds). Once, I tried to optimise one problem (https://github.com/Saylenty/algorithm_with_dots-matrices) trying to solve it using ordered set, but this was not a good idea. |
@saylenty +1 |
Well, it is true too. OrderedDict is written in python (vs C). What if we do this instead? (This will not break any existing code either)
|
@kbandla I like this option... but tbh my favorite solution is to not implement this at all :-) the HTTP protocol spec does not dictate any order in the headers, so dpkt is solid there. If someone wants them in order for their specific use case then it's easy to write their own parse function and feed it tcp.data. |
👍 @obormot. lets not implement this. go ahead and remove it @sunhao2014 (ordereddict support) |
Sure. I'll close this PR and send a new PR that only contains the added http invalid test cases. |
@kbandla , Personally, I would rather implement this feature using OrderedDIct as you've written and write a warning only in the documentation that it can be much slower... |
Solve #164, make http.py return ordered headers, also add the related unit test and setup dependencies.
BTW, according to Kiran's suggestion, some invalid http header test cases were added.