Skip to content

A small and easy-to-use library to parse HTTP Archive (HAR) format to .NET objects.

License

Notifications You must be signed in to change notification settings

giacomelli/HarSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HarSharp

Build status Quality status Coverage Status License Nuget

A small and easy-to-use library to parse HTTP Archive (HAR) format to .NET objects.


Introduction

The HTTP Archive (HAR) format as defined in the W3C Specification is an archival format for HTTP transactions that can be used by a web browser to export detailed performance data about web pages it loads.

So, every modern browser nowadays can export HAR with a lot of information about the user navigation. Chrome, for example, can export HAR from Developer Tools, Network tab, right mouse click and "Copy all as HAR".

What I can do with HAR data? Well, there a lot of things I can imagine right now, like:

  • Web performance tests runners
  • Performance analyzers
  • Navigation visualizers

Setup

NuGet

install-package HarSharp

Usage

Deserialize from string

var har = HarConvert.Deserialize(harContent);

Deserialize from file

var har = HarConvert.DeserializeFromFile(fileName);

Listing pages load time

var har = HarConvert.Deserialize(harContent);

foreach(var page in har.Log.Pages)
{
	Console.WriteLine(
	"Page: {0} loaded in {1} milliseconds", 
	page.Title, 
	page.PageTimings.OnLoad);
}

Code philosophy

The idea of HarSharp is simplify and promote the use of HAR in .NET codes and keep closest possible to W3C specification , for this reason the below rules were followed during the library development:

  • Keep the entities and properties names equals to the one defined in the specification, but follow the C# naming guidelines, so, "pages" became "Pages".
  • Keep the properties types closest to the spec, but change when there is a better type on .NET side.
    • string (ISO 8601 - YYYY-MM-DDThh:mm:ss.sTZD): System.DateTime (UTC).
    • string (url): System.Uri.
  • Full documentation using citations from W3C specification.
  • StyleCop validation.
  • FxCop Validation.
  • 100% unit test coverage

FAQ

Having troubles?

Roadmap

  • Serialize HAR entities back to HAR file.

How to improve it?

License

Licensed under the The MIT License (MIT). In others words, you can use this library for developement any kind of software: open source, commercial, proprietary and alien.

About

A small and easy-to-use library to parse HTTP Archive (HAR) format to .NET objects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published