Documentation
¶
Overview ¶
Package models defines the core data structures for HTTP requests, responses, and their associated metadata used throughout the application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HistoricalHttpRequest ¶
type HistoricalHttpRequest struct {
Method string `json:"method"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
Body string `json:"body,omitempty"`
StartTime int64 `json:"startTime"`
}
HistoricalHttpRequest represents a saved request in history
func NewHistoricalHttpRequest ¶
func NewHistoricalHttpRequest(req *HttpRequest, startTime int64) *HistoricalHttpRequest
NewHistoricalHttpRequest creates a historical request from an HttpRequest
type HttpRequest ¶
type HttpRequest struct {
Method string
URL string
Headers map[string]string
Body io.Reader
RawBody string
Name string
IsCancelled bool
Metadata RequestMetadata
MultipartParts []MultipartPart // For multipart/form-data
Warnings []string // Parsing warnings (e.g., unknown method, malformed headers)
}
HttpRequest represents an HTTP request
func NewHttpRequest ¶
func NewHttpRequest(method, url string, headers map[string]string, body io.Reader, rawBody, name string) *HttpRequest
NewHttpRequest creates a new HttpRequest
func (*HttpRequest) ContentType ¶
func (r *HttpRequest) ContentType() string
ContentType returns the content type of the request
func (*HttpRequest) ToStdRequest ¶
func (r *HttpRequest) ToStdRequest() (*http.Request, error)
ToStdRequest converts HttpRequest to standard http.Request
func (*HttpRequest) Validate ¶ added in v0.2.4
func (r *HttpRequest) Validate() *ValidationResult
Validate validates the HTTP request and returns any validation errors
type HttpResponse ¶
type HttpResponse struct {
StatusCode int
StatusMessage string
HttpVersion string
Headers map[string][]string
Body string
BodySizeInBytes int
HeadersSizeBytes int
BodyBuffer []byte
Timing ResponseTiming
Request *HttpRequest
}
HttpResponse represents an HTTP response
func NewHttpResponse ¶
func NewHttpResponse(resp *http.Response, bodyBuffer []byte, timing ResponseTiming, request *HttpRequest) *HttpResponse
NewHttpResponse creates a new HttpResponse from an http.Response
func (*HttpResponse) ContentType ¶
func (r *HttpResponse) ContentType() string
ContentType returns the content type of the response
func (*HttpResponse) GetHeader ¶
func (r *HttpResponse) GetHeader(name string) string
GetHeader returns a header value (case-insensitive)
func (*HttpResponse) IsHTML ¶
func (r *HttpResponse) IsHTML() bool
IsHTML returns true if the response is HTML
func (*HttpResponse) IsJSON ¶
func (r *HttpResponse) IsJSON() bool
IsJSON returns true if the response is JSON
func (*HttpResponse) IsXML ¶
func (r *HttpResponse) IsXML() bool
IsXML returns true if the response is XML
type MultipartPart ¶
type MultipartPart struct {
Name string // Field name
Value string // Field value (for text fields)
FileName string // Original filename (for file uploads)
FilePath string // Local path to the file
ContentType string // MIME type of the content
IsFile bool // Whether this is a file upload
}
MultipartPart represents a part in a multipart/form-data request
type PromptVariable ¶
PromptVariable represents a variable that requires user input
type RequestMetadata ¶
type RequestMetadata struct {
Name string
Note string
NoRedirect bool
NoCookieJar bool
Prompts []PromptVariable
PreScript string // JavaScript to run before the request
PostScript string // JavaScript to run after the response
}
RequestMetadata holds request-level settings
type ResponseTiming ¶
type ResponseTiming struct {
DNSLookup time.Duration
TCPConnection time.Duration
TLSHandshake time.Duration
ServerProcessing time.Duration
ContentTransfer time.Duration
Total time.Duration
}
ResponseTiming contains timing information for the response
type ValidationError ¶ added in v0.2.4
type ValidationError struct {
Field string // Field that failed validation (e.g., "URL", "Header:Content-Type")
Message string // Description of the validation error
}
ValidationError represents a request validation error
func (ValidationError) Error ¶ added in v0.2.4
func (e ValidationError) Error() string
type ValidationResult ¶ added in v0.2.4
type ValidationResult struct {
Errors []ValidationError
}
ValidationResult contains all validation errors for a request
func (*ValidationResult) AddError ¶ added in v0.2.4
func (v *ValidationResult) AddError(field, message string)
AddError adds a validation error to the result
func (*ValidationResult) Error ¶ added in v0.2.4
func (v *ValidationResult) Error() string
Error returns a combined error message for all validation errors
func (*ValidationResult) IsValid ¶ added in v0.2.4
func (v *ValidationResult) IsValid() bool
IsValid returns true if there are no validation errors