Coder Social home page Coder Social logo

httparchive.js's Introduction

HTTPArchive.js

Build Status Dependency Status devDependency Status Coverage Status Total views

JavaScript library to manipulate HTTP Archive 1.2 JSON objects. You can install with Bower or NPM.

Features

  • Import/export HAR objects
  • Validates aginst HAR 1.2 Spec
  • Provides default values for common properties (Dates, Page IDs, etc...)
  • Automatically calculates headersSize when headers are added/removed
  • Export headers into printed header message per RFC2616

TODO

  • Detailed API Docs.
  • Auto-calc body size when body is set
  • Construct XMLHTTPRequest objects with HTTPArchiveRequest data
  • Construct HTTPArchiveRequest object with XMLHTTPRequest response objects

Table of contents

Quick start

Four quick start options are available:

What's included

Within the download you'll find the following files, providing both compiled and minified variations:

HTTPArchive.js/
└── dist
    ├── HTTPArchive.js
    └── HTTPArchive.min.js

Sample Usage

start by creating a new log instance:

var log = new HTTPArchiveLog({
    'creator':{
        'name':'Ahmad'
    }
});

create an HTTPArchivePage object and add to the log.

var page = new HTTPArchivePage({
    'startedDateTime': new Date(),
    'id':'page_62143',
    'title':'Google',
    'comment': null,
    'pageTimings':{
        'onContentLoad':90,
        'onLoad':245
    }
});

log.addPage(page);

create an HTTPArchiveEntry object and add to log.

var entry = new HTTPArchiveEntry({
    'pageref':'page_62143',
    'startedDateTime': new Date()
});

log.addEntry(entry);

set the entry's HTTPArchiveRequest object

entry.request = new HTTPArchiveRequest({
    'method': 'GET',
    'url': 'http://www.google.ca/',
    'httpVersion': 'HTTP/1.1',
    'queryString':[]
});

lets see the result

log.toJSON();

this should output:

{
    "comment": "",
    "version": 1.2,
    "creator": {
        "name": "Ahmad"
    },
    "browser": {
        "name": null,
        "value": null
    },
    "pages": [{
        "comment": null,
        "id": "page_62143",
        "title": "Google",
        "pageTimings": {
            "onContentLoad": 90,
            "onLoad": 245
        },
        "startedDateTime": "2014-01-05T01:40:18.548Z"
    }],
    "entries": [{
        "pageref": "page_62143",
        "cache": {},
        "timings": {
            "dns": 0,
            "connect": 0,
            "blocked": 0,
            "send": 0,
            "wait": 0,
            "receive": 0
        },
        "startedDateTime": "2014-01-05T01:40:18.549Z",
        "time": "2014-01-05T01:40:18.549Z",
        "request": {
            "method": "GET",
            "url": "http://www.google.ca/",
            "httpVersion": "HTTP/1.1",
            "queryString": [],
            "headersSize": 0,
            "bodySize": 0,
            "cookies": [],
            "headers": []
        },
        "response": null
    }]
}

Documentation

Refer to the Wiki for detailed API documentation.

Bugs and feature requests

Have a bug or a feature request? Please first read the issue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

Compiling Built with Grunt

HTTPArchive.js uses Grunt. If you haven't used Grunt before, be sure to check out the Getting Started guide.

Available Grunt commands

Function Command Description
Build grunt Run grunt to run tests locally and compile the JavaScript files into /dist.
Tests grunt test Runs JSHint and QUnit tests headlessly in PhantomJS (used for CI).
Watch grunt watch This is a convenience method for watching just Less files and automatically building them whenever you save.

Troubleshooting dependencies

Should you encounter problems with installing dependencies or running Grunt commands, uninstall all previous dependency versions (global and local). Then, rerun npm install.

Contributing

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

More over, if your pull request contains JavaScript patches or features, you must include relevant unit tests.

Editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at http://editorconfig.org.

Community

Keep track of development and updates.

Donating

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

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, HTTPArchive.js is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we'll adhere to these rules whenever possible.

Releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major while resetting minor and patch
  • New additions without breaking backward compatibility bumps the minor while resetting the patch
  • Bug fixes and misc changes bumps only the patch

For more information on SemVer, please visit http://semver.org/.

Authors

Ahmad Nassri

License

Licensed under the MIT license.

httparchive.js's People

Watchers

James Cloos 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.