I'm Using Chrome v 49.0.2623.87. I've just started using the HarLib, and I'm loving it.
To get started however, I did have to modify some code that was erroring out.
Steps I took to find the error:
Launch Chrome Developer Tools, open Network tab.
Open webpage.
Right click any of the XHR entries and choose "Save as HAR with content".
Read in the saved using the HarFileReader#readHarFile(InputStream inStream, List<harwarning> warnings) method.
When reading in, rather than just adding a HarWarning to the, my application breaks hard with:
JsonParseException: Unrecognized field '_transferSize' in response element
I've downloaded the latest harlib sources, version 1.2, from the Archives as I didn't know where else to find newer ones. I then manually added a transferSize field, the g/setters and name check in the HarResponse(JsonParser jp, List<harwarning> warnings) constructor. I then received:
Unrecognized field '_error' in response element</harwarning></harwarning>
It's then that I realized that it would be better to just add the HarWarning to the warnings list rather than keep adding any new custom fields.
In my local version, I've updated the code around line 171 of HarResponse to contain the following:
else
{
if (warnings != null){
System.out.println(name + ":" + jp.getText());
warnings.add(new HarWarning("Unrecognized field '" + name
+ "' in response element", jp.getCurrentLocation()));
}
else
throw new JsonParseException("Unrecognized field '" + name
+ "' in response element", jp.getCurrentLocation());
}
}
I can supply a supply a test HAR file if required.
Thanks
Thanks for the report, I'll try to look into it when the semester is over!
I'm also seeing the "Unrecognized field 'error' in response element" for files we're generating with BrowserMob Proxy. I think that this is thrown by Jackson, and there is a way to get Jackson to ignore unrecognized attributes. Could we pass such a configuration parameter onto HarLib?
I noticed like MoGryph that HarLib was moved into the archives folder. Will it continue to be maintained? I found it to be a really good fit for our needs, and easy to use.
Yes, I will continue to maintain HarLib. I will move the new release to the main folder.
I am waiting on another patch before issuing the new release.
Integrated in 1.1.3