HTTP Archive (HAR) Dynamic Object, auto generates values & utility methods for easy manipulation and lookup
- Import/export HAR objects
- Accepts
Date
Objects for all date time fields, automatically converts to ISO format - Generates default values for common properties (Dates, IDs, etc...)
- Automatically calculates
headersSize
- Automatically parse request
url
to createqueryString
objects and setHost
header - Automatically update request url when
queryString
is modified
npm install --save har
var HAR = require('har')
- data:
Object
(a log object)
new HAR.Log({
version: 1.2,
creator: creator,
browser: browser,
comment: 'foo',
})
- page:
Object
(a page object)
var page = new HAR.Page({
id: 'foo',
title: 'hello world',
startedDateTime: new Date()
})
new HAR.Log().addPage(page)
- entry:
Object
(an entry object)
var entry = new HAR.Entry({
startedDateTime: new Date(),
request: request,
response: response
})
new HAR.Log().addEntry(entry)
- data:
Object
(a "beforeRequest" or "afterRequest" objects)
new HAR.CacheEntry({
eTag: 'foo',
hitCount: 10,
expires: new Date(),
lastAccess: new Date(),
comment: 'foo'
})
- data:
Object
(a content object)
new Content({
compression: 20,
mimeType: 'multipart/form-content',
text: 'foo=bar',
encoding: 'base64',
comment: 'hello world'
})
- data:
Object
(a cookie object)
new HAR.Cookie({
name: 'foo',
value: 'bar',
path: '/',
domain: 'www.ahmadnassri.com',
expires: date,
httpOnly: true,
secure: true,
comment: 'foo'
})
- data:
Object
(a creator object)
new HAR.Creator({
name: 'Node HAR',
version: '1.0'
})
- data:
Object
(a browser object)
new HAR.Browser({
name: 'My Browser',
version: '5.0'
})
- data:
Object
(an entry object)
new HAR.Entry({
startedDateTime: new Date(),
request: request,
response: response
})
- data:
Object
(a header object)
new HAR.Header({
name: 'foo',
value 'bar',
comment: 'foo'
})
- data:
Object
(a page object)
new HAR.Page({
id: 'foo',
title: 'hello world',
startedDateTime: new Date(),
pageTimings: {
onLoad: 0,
onContentLoad: 0
},
comment: 'foo'
})
- data:
Object
(a postData Param object)
new HAR.Param({
comment: 'hello',
contentType: 'text/plain',
fileName: 'foo.bar',
name: 'foo',
value: 'bar'
})
- data:
Object
(a postData object)
new HAR.PostData({
comment: 'hello world',
mimeType: 'multipart/form-data',
text: 'foo=bar'
})
- param:
Object
(a postData object)
new HAR.PostData().addParam(param)
- data:
Object
(a query object)
new HAR.Header({
name: 'foo',
value 'bar',
comment: 'foo'
})
- data:
Object
(a request object)
Automatically Calculated Values:
headersSize
bodySize
var request = new HAR.Request({
url: 'https://ahmadnassri.github.io/har-resources/',
headers: [
new Header('foo', 'bar')
],
postData: new PostData({
mimeType: 'text/plain',
text: 'foo'
})
})
// request.headersSize === 44
// request.bodySize === 3
- cookie:
Object
(a cookie object)
new HAR.Request().addCookie(cookie)
- header:
Object
(a header object)
new HAR.Request().addHeader(header)
- query:
Object
(a queryString object)
new HAR.Request().addQuery(query)
- data:
Object
(a response object)
Automatically Calculated Values:
headersSize
bodySize
content.size
var response = new HAR.Response({
status: 200,
statusText: 'OK'
headers: [
new Header('foo', 'bar')
],
content: new PostData({
text: 'foo'
})
})
// response.headersSize === 12
// response.bodySize === 3
// response.content.size === 3
- cookie:
Object
(a cookie object)
new HAR.Response().addCookie(cookie)
- header:
Object
(a header object)
new HAR.Response().addHeader(header)
Donations are welcome to help support the continuous development of this project.