modifier

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entries

type Entries map[string]*Entry

Entries stores all the Entry items

type Entry

type Entry struct {
	// ID is the unique ID for the entry.
	ID string `json:"_id"`
	// StartedDateTime is the date and time stamp of the request start (ISO 8601).
	StartedDateTime time.Time `json:"startedDateTime"`
	// Time is the total elapsed time of the request in milliseconds.
	Time int64 `json:"time"`
	// Request contains the detailed information about the request.
	Request *Request `json:"request"`
	// Response contains the detailed information about the response.
	Response *Response `json:"response,omitempty"`
}

Entry is a individual log entry for a request or response.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger maintains request and response log entries.

func NewLogger

func NewLogger(app *tview.Application, proxychan chan Notification, sitemapchan chan Notification) *Logger

NewLogger returns a HAR logger. The returned logger logs all request post data and response bodies by default.

func (*Logger) AddEntry

func (l *Logger) AddEntry(e Entry)

AddEntry - manually add an entry

func (*Logger) GetEntries

func (l *Logger) GetEntries() map[string]*Entry

GetEntries - return the Entries map

func (*Logger) GetEntry

func (l *Logger) GetEntry(id string) *Entry

GetEntry - Get a specific entry by ID

func (*Logger) ModifyRequest

func (l *Logger) ModifyRequest(req *http.Request) error

ModifyRequest logs requests.

func (*Logger) ModifyResponse

func (l *Logger) ModifyResponse(res *http.Response) error

ModifyResponse logs responses.

func (*Logger) RecordRequest

func (l *Logger) RecordRequest(id string, req *http.Request) error

RecordRequest logs the HTTP request with the given ID. The ID should be unique per request/response pair.

func (*Logger) RecordResponse

func (l *Logger) RecordResponse(id string, res *http.Response) error

RecordResponse logs an HTTP response, associating it with the previously-logged HTTP request with the same ID.

func (*Logger) Reset

func (l *Logger) Reset()

Reset clears the in-memory log of entries.

type Notification

type Notification struct {
	ID        string
	NotifType int // 0 == request, 1 == response
}

Notification channel struct. Holds the element ID and an int for request or response

type Request

type Request struct {
	// Method is the request method (GET, POST, ...).
	Method string `json:"method"`
	// URL is the absolute URL of the request (fragments are not included).
	URL string `json:"url"`
	// HTTPVersion is the Request HTTP version (HTTP/1.1).
	HTTPVersion string `json:"httpVersion"`
	// BodySize is the size of the request body (POST data payload) in bytes. Set
	// to -1 if the info is not available.
	BodySize int64 `json:"bodySize"`

	Raw  []byte // the raw body
	Host string
	TLS  bool
}

Request holds data about an individual HTTP request.

func NewRequest

func NewRequest(req *http.Request) (*Request, error)

NewRequest constructs and returns a Request from req. An error is returned (and req.Body may be in an intermediate state) if an error is returned from req.Body.Read.

type Response

type Response struct {
	// Status is the response status code.
	Status int `json:"status"`
	// StatusText is the response status description.
	StatusText string `json:"statusText"`
	// HTTPVersion is the Response HTTP version (HTTP/1.1).
	HTTPVersion string `json:"httpVersion"`
	// RedirectURL is the target URL from the Location response header.
	RedirectURL string `json:"redirectURL"`
	// Headers stores the response headers
	Headers http.Header `json:"headers"`
	// BodySize is the size of the request body (POST data payload) in bytes. Set
	// to -1 if the info is not available.
	BodySize int64 `json:"bodySize"`

	Raw []byte // the raw body
}

Response holds data about an individual HTTP response.

func NewResponse

func NewResponse(res *http.Response) (*Response, error)

NewResponse constructs and returns a Response from resp.

Jump to

Keyboard shortcuts

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