response

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	UniqueIdentifier string                    // Unique ID for the request, generated internally
	URL              string                    // URL the request was made to
	Method           string                    // HTTP method used (e.g., GET, POST)
	RequestPayload   any                       // Payload sent with the request
	Options          *options.Option           // Configuration options for the request
	RequestTime      int64                     // Timestamp of when the request was initiated
	ResponseTime     int64                     // Timestamp of when the response was received
	ProcessedTime    int64                     // Duration taken to process the request
	Status           string                    // HTTP status message (e.g., "200 OK")
	StatusCode       int                       // HTTP status code (e.g., 200, 404)
	Proto            string                    // Protocol used (e.g., HTTP/1.1)
	Header           http.Header               // Headers included in the response
	ContentLength    int64                     // Length of the response content
	TransferEncoding []string                  // Transfer encoding details from the response
	CompressionType  options.CompressionType   // Type of compression applied to the response
	Uncompressed     bool                      // Indicates if the response was uncompressed
	Cookies          []*http.Cookie            // Cookies received with the response
	AccessTime       time.Duration             // Time taken to complete the request
	Body             options.WriteCloserBuffer // The response body as a buffer
	Error            error                     // Any error encountered during the request
	TLS              *tls.ConnectionState      // Details about the TLS connection
	Redirected       bool                      // Indicates if the request was redirected
	Location         string                    // New location if the request was redirected
}

Response represents the HTTP response along with additional metadata

func New

func New(url string, method string, payload any, opt *options.Option) Response

New initializes a new Response instance with basic details

func (*Response) Bytes

func (r *Response) Bytes() []byte

Bytes returns the response body as a byte slice

func (*Response) Len

func (r *Response) Len() int64

Len returns the length of the response body If there is no body, it returns -1 to indicate there is an issue

func (*Response) PopulateResponse

func (r *Response) PopulateResponse(resp *http.Response, start time.Time)

PopulateResponse populates the Response struct with data from an http.Response

func (*Response) String

func (r *Response) String() string

String returns the response body as a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳