parser

package
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package parser parses SAZ files (Fiddler logs) to an array of sessions, which contain all about network connections, requests and responses.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flag added in v0.0.2

type Flag struct {
	XMLName xml.Name `xml:"SessionFlag"`
	Name    string   `xml:"N,attr"`
	Value   string   `xml:"V,attr"`
}

Flag contains a property of a deserialized network session, which are not included in request or response headers. Originated at https://docs.telerik.com/fiddlercore/api/fiddler.session.

type Flags added in v0.0.2

type Flags struct {
	XMLName xml.Name `xml:"SessionFlags"`
	Flags   []Flag   `xml:"SessionFlag"`
}

Flags contain properties of a deserialized network session, which are not included in request or response headers. Originated at https://docs.telerik.com/fiddlercore/api/fiddler.session.

type Session

type Session struct {
	XMLName      xml.Name `xml:"Session"`
	Number       int
	Timers       Timers `xml:"SessionTimers"`
	Flags        Flags  `xml:"SessionFlags"`
	Request      *http.Request
	Response     *http.Response
	RequestBody  []byte
	ResponseBody []byte
}

Session represents a deserialized network session. Originated at https://docs.telerik.com/fiddlercore/api/fiddler.session.

func ParseFile

func ParseFile(fileName string) ([]Session, error)

ParseFile prses a file to an array of network sessions.

Example

Parse the content of `foo.saz` and print the count of network sessions.

package main

import (
	"fmt"

	"github.com/prantlf/saz-tools/pkg/parser"
)

func main() {
	sessions, err := parser.ParseFile("foo.saz")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%d network sessions found.", len(sessions))
}
Output:

42 network sessions found.

func ParseReader

func ParseReader(reader io.ReaderAt, size int64) ([]Session, error)

ParseReader parses a file content passed by a reader to an array of network sessions.

Example

Parse the content of `foo.saz` and print the total size of all responses.

package main

import (
	"fmt"
	"io"

	"github.com/prantlf/saz-tools/pkg/parser"
)

func main() {
	var reader io.ReaderAt
	var size int64
	sessions, err := parser.ParseReader(reader, size)
	if err != nil {
		panic(err)
	}
	var total int64
	for index := range sessions {
		total += sessions[index].Response.ContentLength
	}
	fmt.Printf("The total downloaded size was %d bytes.", total)
}
Output:

The total downloaded size was 44040192 bytes.

type Timers added in v0.0.2

type Timers struct {
	XMLName             xml.Name `xml:"SessionTimers"`
	ClientConnected     string   `xml:"ClientConnected,attr"`
	ClientBeginRequest  string   `xml:"ClientBeginRequest,attr"`
	GotRequestHeaders   string   `xml:"GotRequestHeaders,attr"`
	ClientDoneRequest   string   `xml:"ClientDoneRequest,attr"`
	GatewayTime         string   `xml:"GatewayTime,attr"`
	DNSTime             string   `xml:"DNSTime,attr"`
	TCPConnectTime      string   `xml:"TCPConnectTime,attr"`
	HTTPSHandshakeTime  string   `xml:"HTTPSHandshakeTime,attr"`
	ServerConnected     string   `xml:"ServerConnected,attr"`
	FiddlerBeginRequest string   `xml:"FiddlerBeginRequest,attr"`
	ServerGotRequest    string   `xml:"ServerGotRequest,attr"`
	ServerBeginResponse string   `xml:"ServerBeginResponse,attr"`
	GotResponseHeaders  string   `xml:"GotResponseHeaders,attr"`
	ServerDoneResponse  string   `xml:"ServerDoneResponse,attr"`
	ClientBeginResponse string   `xml:"ClientBeginResponse,attr"`
	ClientDoneResponse  string   `xml:"ClientDoneResponse,attr"`
}

Timers contain begin and end times of phases of a deserialized network session. Originated at https://docs.telerik.com/fiddlercore/api/fiddler.sessiontimers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL