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
HAR #1464
HAR #1464
Conversation
The post Data field is missing in case of POST method (was missing in original har_extractor too). Would it possible to add that? Something like this, maybe: if flow.request.method == "POST":
entry["request"]["postData"] = format_post_data(flow.request) and def format_params(obj):
if obj:
return [{"name": k, "value": unicode(v, errors='ignore')} for k, v in obj.items()]
return ""
def format_post_data(obj):
content_type = obj.headers.get("content-type", "")
post_data = {"mimeType" : content_type}
is_valid_content_type = "application/x-www-form-urlencoded" in content_type.lower()
if is_valid_content_type:
post_data["params"] = format_params(obj.urlencoded_form)
post_data["text"] = unicode(obj.content, errors='ignore')
return post_data |
One more thing, regarding cookies (in response), they are coming like (same behavior in har_extractor too):
While each one should be a separate field as in the specification:
|
This looks great. So much clearer than what we had before 👍 |
245d93c
to
ec54180
Compare
return dt.replace(tzinfo=pytz.timezone("UTC")).isoformat() | ||
|
||
|
||
def format_cookies(cookies): |
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.
How can I unit test these functions? examples
directory has no __init__.py
so har_dump
can't directly be imported!
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.
Based on the stuff in test_examples:
m, sc = tscript("har_dump.py", six.moves.shlex_quote(path))
format_datetime = sc.ns["format_datetime"]
# work with format_datetime
Not really ideal, but I feel that's still better than making the examples directory a module.
bd9bf3c
to
f5d7707
Compare
@mkagenius Should the @mhils This is ready for review! |
@dufferzafar Good question. I am also not sure as the specification is not too clear about that. But I checked what chrome does when we do |
@mkagenius If chrome does this, then I think we should too. It seems like the correct thing to do anyways. |
|
||
elif 'max-age' in cookie_attrs: | ||
try: | ||
max_age = int(cookie_attrs['Max-Age']) |
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.
Do we have a policy about cookie attribute capitalisation?
Sometimes we use only-lowercase, sometimes mixed...
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.
There's no policy, i guess because the _kconv
function converts these keys to lowercase.
IMO, we should keep using mixed cases just to show that they don't matter.
The HAR Spec says that the field can be left out by applications that don't group by pages. http://www.softwareishard.com/blog/har-12-spec/#log
The HAR spec isn't really clear on whether this should be the case, but Google Chrome does this, so I think we should too.
So that tests pass on 32bit systems too
This adds a script that can dump flows as HAR but does not depend on harparser.
Tasks:
.zhar
Compressionctx.log
Append to file on every request, rather than writing at end(forgot that this is json!)Read har file?(Separate PR if at all)New Fields:
text
in response contentpostData
forPOST
,PUT
,PATCH
serverIPAddress
(we have no unique ids for connections)connection
(mitmproxy has no concept of pages)pages
Fixes #1320