HAR (http Archive) is a common file format for storing HTTP request/response information, based on JSON. The advent of this format allows the HTTP monitoring tool to export the collected data in a common format, which can be used by other HTTP analysis tools that support har, including Firebug,httpwatch,fiddler, to analyze the site's performance bottlenecks. The current HAR specification is the latest version of Har 1.2. The Har file must be UTF-8 encoded and there is no BOM matter.
View the url:http://www.softwareishard.com/har/viewer/of the Har file data
HAR data structure:
A har file is a JSON object, as follows:
{
"Log": {
"Version": "1.2",
"Creator": {},
"Browser": {},
"Pages": [],
"Entries": [],
"Comment": ""
}
}
Version [string]–, default = 1.1.
Creator [object]– creates the program name and version information for the Har file.
Browser [object, optional]– browser name and version information.
pages [Array, optional]– page list, this field can be omitted if the app does not support grouping by page.
Entries [array]– List of all HTTP requests.
Comment [string, optional] (new in 1.2) – comment.
Note: Each page corresponds to an object, and each HTTP request corresponds to an object. If the HTTP Monitoring Analysis tool cannot group requests by page, then it is empty.
<creator> & <browser>
The structure of the two objects is the same
"Creator": {
"Name": "Firebug",
"Version": "1.6",
"Comment": "",
}
"Browser": {
"Name": "Firefox",
"Version": "3.6",
"Comment": ""
}
Name [String]–har the build tool or browser.
Version [String]–har the build tool or browser.
Comment [string, optional] (new in 1.2) – comment.
<pages>
This object saves a list of pages in the following format:
"Pages": [
{
"Starteddatetime": "2009-04-16t12:07:25.123+01:00",
"id": "Page_0",
"title": "Test page",
"Pagetimings": {...},
"Comment": ""
}
]
Starteddatetime [string]– page starts loading time (format ISO 8601–yyyy-mm-ddthh:mm:ss.stzd, for example 2009-07-24t19:20:30.45+01:00).
ID [String]–page's unique identifier, entry will use this ID to associate with the page.
Title [string]– page title.
pagetimings[object]– detailed time information during page loading.
Comment [string, optional] (new in 1.2) – comment.
<pageTimings>
This object describes the point in time at which each event occurred during page loading. All the time is measured in milliseconds. If some time cannot be calculated, then the corresponding field is set to-1.
"Pagetimings": [
{
"Oncontentload": 1720,
"OnLoad": 2500,
"Comment": ""
}
]
oncontentload [number, optional]– page content load time, in milliseconds (page.starteddatetime) relative to the start load time of the page. If the time does not apply to the current request, then set to-1.
onLoad [number, optional]– page load time (that is, the time the OnLoad event is triggered). The number of milliseconds (page.starteddatetime) relative to the start load time of the page. If the time does not apply to the current request, then set to-1.
Comment [string, optional] (new in 1.2) – comment.
Because different browser implementations do not, the Oncontentload property may be triggered on behalf of the Domcontentload event, or it may represent document.readystate equals interactive.
<entries>
This object contains an array in which the contents of each element of the array are the appropriate information for an HTTP request. Using Starteddatetime to sort words can speed up the data export. The Har analysis tool ensures that this array is sorted by Starteddatetime.
"Entries": [
{
"PageRef": "Page_0",
"Starteddatetime": "2009-04-16t12:07:23.596z",
"Time": 50,
"Request": {...},
"Response": {...},
"Cache": {...},
"Timings": {},
"Serveripaddress": "10.0.0.1",
"Connection": "52492",
"Comment": ""
}
]
PAGEREF [String, Unique, optional]– page ID, if you do not support grouping by page, then the field is empty.
Starteddatetime [string]– Request start time (format ISO 8601–yyyy-mm-ddthh:mm:ss.stzd).
Time [number]– requests are consumed in milliseconds. This value is the timings of all available (values not-1) in the timing object.
Request [object]– details of requests.
Response [Details of the object]– response.
cache [object]– Cached usage information.
Timings [object]– Request/Response process (round trip) for detailed time information.
serveripaddress [string, optional] (new in 1.2) – The server IP address.
Connection [string, optional] (new in 1.2) a unique indication of the –TCP/IP connection. If the program is not supported, ignore this field directly.
Comment [string, optional] (new in 1.2) – comment.
<request>
This object contains the details of the request
"Request": {
"Method": "GET",
"url": "Http://www.example.com/path/?param=value",
"Httpversion": "http/1.1",
"Cookies": [],
"Headers": [],
"QueryString": [],
"PostData": {},
"Headerssize": 150,
"Bodysize": 0,
"Comment": "",
}
method [string]– Request Methods (Get,post, ...).
URL [string]– The absolute URL of the request (fragments is not included).
httpversion [string]– Request HTTP version.
Cookies [Array]–cookie list.
headers [Array]–header list.
queryString [object]– query string information.
PostData [object, optional]–post data information.
headerssize [number]–http the number of bytes in the request header. If not available, set to-1.
bodysize [number]– Request body byte number (post data). If not available, set to-1.
Comment [string, optional] (new in 1.2) – comment.
<response>
This object contains detailed information about the response.
"Response": {
"Status": 200,
"StatusText": "OK",
"Httpversion": "http/1.1",
"Cookies": [],
"Headers": [],
"Content": {},
"RedirectURL": ",
"Headerssize": 160,
"Bodysize": 850,
"Comment": ""
}
Status [number]– response state.
StatusText [string]– Response status Description.
httpversion [String]–http version.
Cookies [Array]–cookie list.
headers [Array]–header list.
Content [object]– details of the response.
RedirectURL [redirect URL in string]–location response header.
headerssize [number]*–http the number of bytes in the request header. If not available, set to-1.
Bodysize [the number of body bytes received by number]–. If the response is from cache (304), then set to 0. If not available, set to-1.
Comment [string, optional] (new in 1.2) – comment.
Note: The headerssize– response header size is calculated only for headers received from the server. Headers added by the browser are not counted, but will be added to the header list.
<cookies>
This object contains all the cookies (used in and).
"Cookies": [
{
"Name": "TestCookie",
"Value": "Cookie value",
"Path": "/",
"Domain": "www.janodvarko.cz",
"Expires": "2009-07-24t19:20:30.123+02:00",
"HttpOnly": false,
"Secure": false,
"Comment": "",
}
]
Name [String]–cookie.
Value [String]–cookie value.
path [string, optional]–cookie Path.
domain [string, optional]–cookie domain name.
expires [string, optional]–cookie expiration time. (Format ISO 8601–yyyy-mm-ddthh:mm:ss.stzd, for example 2009-07-24t19:20:30.123+02:00).
HttpOnly [Boolean, optional]– if the cookie is only valid under HTTP, this value is set to true, otherwise set to false.
Secure [Boolean, optional] (new in 1.2) – This value is set to True if the cookie is sent over SSL, otherwise it is set to false.
Comment [string, optional] (new in 1.2) – comment.
This object contains all headers (which can be used in lt;request>and<response>)
"Headers": [
{
"Name": "Accept-encoding",
"Value": "Gzip,deflate",
"Comment": ""
},
{
"Name": "Accept-language",
"Value": "en-us,en;q=0.5",
"Comment": ""
}
]
<queryString>
This object contains all the Paramter-value pairs (embedded in the object) in the query string.
"QueryString": [
{
"Name": "param1",
"Value": "Value1",
"Comment": ""
},
{
"Name": "param1",
"Value": "Value1",
"Comment": ""
}
]
<postData>
This object describes the data of the post (embedded in the object)
"PostData": {
"MimeType": "Multipart/form-data",
"Params": [],
"Text": "Plain Posted data",
"Comment": ""
}
MimeType [MIME type of string]–post data.
params [array]–post parameter list (in case of URL encoded parameters).
text [String]–post (Plain text posted data) in plain text form.
Comment [string, optional] (new in 1.2) – comment.
Note: The text and params fields are mutually exclusive.
<params>
Post request parameter list (embedded in object)
"Params": [
{
"Name": "ParamName",
"Value": "Paramvalue",
"FileName": "Example.pdf",
"ContentType": "Application/pdf",
"Comment": ""
}
]
Name [string]–post parameter name.
Value [string, the optional]–post parameter, or the contents of the post file.
FileName [String, the file name of the optional]–post file.
ContentType [String, the type of the optional]–post file.
Comment [string, optional] (new in 1.2) – comment.
<content>
This object describes the details of the response content (embedded in the object)
"Content": {
"Size": 33,
"Compression": 0,
"MimeType": "text/html; Charset= "Utf-8",
"Text": "N",
"Comment": ""
}
Size [number]– Returns the number of bytes of content. If the content is not compressed, it should be equal to response.bodysize, and if it is compressed, it will be greater than response.bodysize.
compression [number, optional]– bytes saved. If this information cannot be provided, this field is ignored.
MimeType [string]– The MIME type of the response text (the value of the Content-type response header). The character set of the Mimie type is also included.
text [string, optionally]– the response body returned from the server or content loaded from the browser cache. This field can only be populated with text-based content. The contents of the field can be either HTTP decoded (decompressed & unchunked) text, or the response content encoded (for example, base64). If the information is not available, this field is ignored.
encoding [string, optional] (new in 1.2) – The encoding format of the response content, such as "Base64″." If the contents of the Text field are HTTP decoded (decompressed & unchunked), this field is ignored.
Comment [string, optional] (new in 1.2) – comment.
Before setting the Text field, the HTTP response content has been decoded (decompressed & unchunked), and the original character encoding is converted to UTF-8. The field contents can also be encoded using Base64, but the Har tool must have the ability to decode the base64. The field encoding can also include binary content into the Har file.
Here is another example of the original response:
"Content": {
"Size": 33,
"Compression": 0,
"MimeType": "text/html; Charset= "Utf-8",
"Text": "Pgh0bww+pghlywq+pc9ozwfkpjxib2r5lz48l2h0bww+xg4=",
"Encoding": "Base64",
"Comment": ""
}
<cache>
This object contains the browser cache information for the hit
"Cache": {
"Beforerequest": {},
"Afterrequest": {},
"Comment": ""
}
Beforerequest [object, optional]– the state of the cache before the request. If the information is not available, you can omit this field.
Afterrequest [object, optional]– the state of the cache after the request. If the information is not available, you can omit this field.
Comment [string, optional] (new in 1.2) – comment.
If the cache information is empty, then the object is as follows (or you can delete the cache field directly):
"Cache": {}
If the cached information is not available before the request, and the content is not cached after the request, the object is as follows:
"Cache": {
"Afterrequest": null
}
If no cache exists before and after the request, the object is as follows:
"Cache": {
"Beforerequest": null,
"Afterrequest": null
}
The following object indicates that the request was not cached before, but after the request, the downloaded content is present in the local cache.
"Cache": {
"Beforerequest": null,
"Afterrequest": {
"Expires": "2009-04-16t15:50:36",
"Lastaccess": "2009-16-02t15:50:34",
"ETag": ",
"HitCount": 0,
"Comment": ""
}
}
The Beforerequest and Afterrequest objects use the same structure as the following:
"Beforerequest": {
"Expires": "2009-04-16t15:50:36",
"Lastaccess": "2009-16-02t15:50:34",
"ETag": ",
"HitCount": 0,
"Comment": "" "
}
expires [string, optional]– cache expiration time.
lastaccess [string]– The last time the cache was accessed.
ETag [String]–etag
HitCount [Number of times the number]– cache has been accessed.
Comment [string, optional] (new in 1.2) – Comment
<timings>
This object describes the various stages of the request/response process. The time is measured in milliseconds.
"Timings": {
"blocked": 0,
"DNS":-1,
"Connect": 15,
"Send": 20,
"Wait": 38,
"Receive": 12,
"SSL":-1,
"Comment": ""
}
blocked [number, optional]– the time to wait in the queue when establishing a network connection. If the time is not available for the current request, set to-1.
DNS [number, optional]–dns query time. If the time is not available for the current request, set to-1.
Connect [number, optional]– the time it takes to establish a TCP connection. If the time is not available for the current request, set to-1.
Send [number]– The time it takes to send an HTTP request to the server.
Wait [number]– waits for the server to return the response time.
Receive [number]– The time it takes to receive the server response (or cache).
SSL [number, optional] (new in 1.2) –SSL/TLS validation takes time. If the field is defined, the time will also be included in the Connect field (for backwards compatibility with HAR1.1). If the time is not available for the current request, set to-1.
Comment [string, optional] (new in 1.2) – comment.
Send,wait,receive time is mandatory and cannot be negative. If the export tool does not provide time such as Blocked,dns,connect and SSL, then these times can be ignored. If the tool can provide these times, but not applicable, you can set these values to-1. For example, when a request uses an existing connection, connect is set to-1.
The time spent on a request equals the sum of these times, and does not include a value of-1.
Entry.time = = entry.timings.blocked + entry.timings.dns + entry.timings.connect + entry.timings.send + Entry.timings.wait + entry.timings.receive
Custom Fields
The HAR specification allows custom fields, but follows the following rules:
Custom fields and elements must begin with an underscore (the field in the specification must not begin with an underscore)
The Har tool must ignore all custom fields and elements if this har file is not generated by the current Har tool.
When the Har tool does not know how to parse non-custom fields, ignore them.
The Har tool can refuse to parse this file when it contains a non-custom field that has been deprecated.
Version format
The version number of the HAR specification has the following rules:
< major version number >.< sub version number >
The major version number represents the backward compatibility of the specification, and the secondary version number represents the incremental modification. Therefore, any backward-compatible modifications increase the version number of the pair. If an existing field is discarded, the major version number is incremented (for example, 2.0).
Examples:
1.2-1.3 (backwards compatible)
1.111-1.112 (backwards compatible)
1.5-2.0 (2.0 incompatible 1.5)
If the Har tool only supports HAR1.1, then the following code can be used to detect incompatible versions.
if (majorversion! = 1 | | MinorVersion < 1)
{
Throw "incompatible version";
}
In this example, if the version of the parsed file is 0.8,0.9,1.0 and so on, then the tool throws an exception, but the 1.1, 1.2, 1.112, etc. versions can be parsed. The 2.x version rejects parsing directly.
Original: http://www.softwareishard.com/blog/har-12-spec/
Google group:http://groups.google.com/group/http-archive-specification "Need Fq"
Finish
Author: Jeremywei | may be reproduced, but must be in the form of hyperlinks to indicate the original source and author information and copyright notice
Reprinted from: http://weizhifeng.net/har-12-spec-chinese-edtion.html
Goto: HAR (HTTP Archive) specification