Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    harpublic

    HAR version License

    HTTP Archive (HAR) Dynamic Object, auto generates values & utility methods for easy manipulation and lookup

    Build Status Downloads Code Climate Coverage Status Dependencies

    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 create queryString objects and set Host 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)

    new HAR.CacheEntry({
      eTag: 'foo',
      hitCount: 10,
      expires: new Date(),
      lastAccess: new Date(),
      comment: 'foo'
    })

    HAR.Content(data)

    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)

    new HAR.Creator({
      name: 'Node HAR',
      version: '1.0'
    })

    HAR.Browser(data)

    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)

    new HAR.Param({
      comment: 'hello',
      contentType: 'text/plain',
      fileName: 'foo.bar',
      name: 'foo',
      value: 'bar'
    })

    HAR.PostData(data)

    new HAR.PostData({
      comment: 'hello world',
      mimeType: 'multipart/form-data',
      text: 'foo=bar'
    })

    HAR.PostData.addParam(param)

    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)

    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)

    new HAR.Request().addQuery(query)

    HAR.Response(data)

    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.

    Gratipay PayPal Flattr Bitcoin

    License

    MIT © Ahmad Nassri

    Keywords

    install

    npm i har

    Downloadslast 7 days

    31

    version

    1.0.0

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar