Giter VIP home page Giter VIP logo

har-expander's Introduction

HAR Expander version License

Expands HTTP Archive (HAR) objects with helpful utility properties and a sprinkle of magic.

Build Status Downloads Code Climate Coverage Status Dependencies

Utility Properties

Request
  • creates a new property queryObj as a standard object from queryString array
  • creates a new property headersObj as a standard object from headers array
  • creates a new property cookieObj as a standard object from cookies array
  • parses url property for any query string params and adds them to queryString & queryObj
  • creates a new property fullUrl by combining url with queryString
  • creates a new property uriObj by parsing fullUrl
  • restores url to queryString-less state after parsing
  • creates a new property postData.jsonObj from parsing req.postData.text with appropriate mimeType
  • creates a new property postData.paramsObj from postData.params array
  • creates a new property postData.paramsObj from parsing req.postData.text with appropriate mimeType (multipart/form-data, application/x-www-form-urlencoded)
Response
  • creates a new property headersObj as a standard object from headers array
  • creates a new property cookieObj as a standard object from cookies array
  • creates a new property redirectURLObj by parsing redirectURL
  • creates a new property content.jsonObj from parsing req.postData.text with appropriate mimeType

Example

Before
{
  "log": {
    "version": "1.2",
    "creator": {
      "name": "har-expander",
      "version": "1.0"
    },
    "entries": [
      {
        "startedDateTime": "2015-02-10T07:33:17.146Z",
        "time": 110,
        "request": {
          "method": "GET",
          "url": "http://mockbin.com/har?key=value",
          "httpVersion": "HTTP/1.1",
          "headers": [
            { "name": "Host", "value": "mockbin.com" },
            { "name": "Connection", "value": "keep-alive" }
          ],
          "queryString": [
            { "name": "foo", "value": "bar"}
          ],
          "cookies": [
            { "name": "foo", "value": "bar" }
          ],
          "headersSize": 0,
          "bodySize": 0
        },
        "response": {
          "status": 200,
          "statusText": "OK",
          "httpVersion": "HTTP/1.1",
          "headers": [
            { "name": "Date", "value": "Tue, 10 Feb 2015 07:33:16 GMT" },
            { "name": "X-Powered-By", "value": "mockbin.com" },
            { "name": "Content-Type", "value": "text/html; charset=utf-8" }
          ],
          "cookies": [
            { "name": "foo", "value": "bar" }
          ],
          "content": {
            "size": 0,
            "mimeType": "application/json",
            "text": "{\"foo\": \"bar\"}"
          },
          "redirectURL": "",
          "headersSize": 0,
          "bodySize": 0
        },
        "cache": {},
        "timings": {
          "send": -1,
          "wait": -1,
          "receive": -1
        }
      }
    ]
  }
}
After
{
  "log": {
    "version": "1.2",
    "creator": {
      "name": "har-expander",
      "version": "1.0"
    },
    "entries": [
      {
        "startedDateTime": "2015-02-10T07:33:17.146Z",
        "time": 110,
        "request": {
          "method": "GET",
          "url": "http://mockbin.com/har",
          "httpVersion": "HTTP/1.1",
          "headers": [
            { "name": "Host", "value": "mockbin.com" },
            { "name": "Connection", "value": "keep-alive" }
          ],
          "queryString": [
            { "name": "foo", "value": "bar"}
          ],
          "cookies": [
            { "name": "foo", "value": "bar" }
          ],
          "headersSize": 0,
          "bodySize": 0,
          "queryObj": {
            "foo": "bar",
            "key": "value"
          },
          "headersObj": {
            "connection": "keep-alive",
            "host": "mockbin.com",
            "cookie": "foo=bar"
          },
          "cookiesObj": {
            "foo": "bar"
          },
          "uriObj": {
            "protocol": "http:",
            "slashes": true,
            "auth": null,
            "host": "mockbin.com",
            "port": null,
            "hostname": "mockbin.com",
            "hash": null,
            "search": "?foo=bar&key=value",
            "query": {
              "foo": "bar",
              "key": "value"
            },
            "pathname": "/har",
            "path": "/har?foo=bar&key=value",
            "href": "http://mockbin.com/har?foo=bar&key=value"
          },
          "fullUrl": "http://mockbin.com/har?foo=bar&key=value"
        },
        "response": {
          "status": 200,
          "statusText": "OK",
          "httpVersion": "HTTP/1.1",
          "headers": [
            { "name": "Date", "value": "Tue, 10 Feb 2015 07:33:16 GMT" },
            { "name": "X-Powered-By", "value": "mockbin.com" },
            { "name": "Content-Type", "value": "text/html; charset=utf-8" }
          ],
          "cookies": [
            { "name": "foo", "value": "bar" }
          ],
          "content": {
            "size": 0,
            "mimeType": "application/json",
            "text": "{\"foo\": \"bar\"}",
            "jsonObj": {
              "foo": "bar"
            },
            "paramsObj": false
          },
          "redirectURL": "",
          "headersSize": 0,
          "bodySize": 0,
          "headersObj": {
            "content-type": "text/html; charset=utf-8",
            "x-powered-by": "mockbin.com",
            "date": "Tue, 10 Feb 2015 07:33:16 GMT",
            "cookie": "foo=bar"
          },
          "cookiesObj": {
            "foo": "bar"
          },
          "redirectURLObj": {
            "protocol": null,
            "slashes": null,
            "auth": null,
            "host": null,
            "port": null,
            "hostname": null,
            "hash": null,
            "search": "",
            "query": {},
            "pathname": null,
            "path": null,
            "href": ""
          }
        },
        "cache": {},
        "timings": {
          "send": -1,
          "wait": -1,
          "receive": -1
        }
      }
    ]
  }
}

Install

npm install --save har-expander

Usage


  Usage: har-expander [options]

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

API

har-expander()

var expander = require('har-expander')

// expand full HAR log
var expandedHAR = expander(HAR)

// expand request object only
var expandedReq = expander.request(HAR.log.entries[0].request)

// expand response object only
var expandedRes = expander.request(HAR.log.entries[0].response)

Support

Donations are welcome to help support the continuous development of this project.

Gratipay PayPal Flattr Bitcoin

License

MIT © Ahmad Nassri

har-expander's People

Contributors

ahmadnassri avatar feross avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.