node-har
node-har copied to clipboard
HTTP Archive (HAR) Dynamic Object
HAR

HTTP Archive (HAR) Dynamic Object, auto generates values & utility methods for easy manipulation and lookup
Features
- 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
TODO
- [ ] Automatically parse request
url
to createqueryString
objects and setHost
header - [ ] Automatically update request url when
queryString
is modified
Install
npm install --save har
API
var HAR = require('har')
HAR.Log(data)
-
data:
Object
(a log object)
new HAR.Log({
version: 1.2,
creator: creator,
browser: browser,
comment: 'foo',
})
HAR.Log.addPage(page)
-
page:
Object
(a page object)
var page = new HAR.Page({
id: 'foo',
title: 'hello world',
startedDateTime: new Date()
})
new HAR.Log().addPage(page)
HAR.Log.addEntry(entry)
-
entry:
Object
(an entry object)
var entry = new HAR.Entry({
startedDateTime: new Date(),
request: request,
response: response
})
new HAR.Log().addEntry(entry)
HAR.CacheEntry(data)
-
data:
Object
(a "beforeRequest" or "afterRequest" objects)
new HAR.CacheEntry({
eTag: 'foo',
hitCount: 10,
expires: new Date(),
lastAccess: new Date(),
comment: 'foo'
})
HAR.Content(data)
-
data:
Object
(a content object)
new Content({
compression: 20,
mimeType: 'multipart/form-content',
text: 'foo=bar',
encoding: 'base64',
comment: 'hello world'
})
HAR.Cookie(data)
-
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'
})
HAR.Creator(data)
-
data:
Object
(a creator object)
new HAR.Creator({
name: 'Node HAR',
version: '1.0'
})
HAR.Browser(data)
-
data:
Object
(a browser object)
new HAR.Browser({
name: 'My Browser',
version: '5.0'
})
HAR.Entry(data)
-
data:
Object
(an entry object)
new HAR.Entry({
startedDateTime: new Date(),
request: request,
response: response
})
HAR.Header(data)
-
data:
Object
(a header object)
new HAR.Header({
name: 'foo',
value 'bar',
comment: 'foo'
})
HAR.Page(data)
-
data:
Object
(a page object)
new HAR.Page({
id: 'foo',
title: 'hello world',
startedDateTime: new Date(),
pageTimings: {
onLoad: 0,
onContentLoad: 0
},
comment: 'foo'
})
HAR.Param(data)
-
data:
Object
(a postData Param object)
new HAR.Param({
comment: 'hello',
contentType: 'text/plain',
fileName: 'foo.bar',
name: 'foo',
value: 'bar'
})
HAR.PostData(data)
-
data:
Object
(a postData object)
new HAR.PostData({
comment: 'hello world',
mimeType: 'multipart/form-data',
text: 'foo=bar'
})
HAR.PostData.addParam(param)
-
param:
Object
(a postData object)
new HAR.PostData().addParam(param)
HAR.Query(data)
-
data:
Object
(a query object)
new HAR.Header({
name: 'foo',
value 'bar',
comment: 'foo'
})
HAR.Request(data)
-
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
HAR.Request.addCookie(cookie)
-
cookie:
Object
(a cookie object)
new HAR.Request().addCookie(cookie)
HAR.Request.addHeader(header)
-
header:
Object
(a header object)
new HAR.Request().addHeader(header)
HAR.Request.addQuery(query)
-
query:
Object
(a queryString object)
new HAR.Request().addQuery(query)
HAR.Response(data)
-
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
HAR.Response.addCookie(cookie)
-
cookie:
Object
(a cookie object)
new HAR.Response().addCookie(cookie)
HAR.Response.addHeader(header)
-
header:
Object
(a header object)
new HAR.Response().addHeader(header)
Support
Donations are welcome to help support the continuous development of this project.
License
MIT © Ahmad Nassri