request

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package request contains all the things used to create requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRequest

func BuildRequest(processedRequest Request) (*http.Request, error)

BuildRequest builds an http.Request from a configured request.Request

func ParseURL

func ParseURL(base string, paths ...string) string

ParseURL parses the configuration to generate the final URL that the request will be sent to

Types

type ConfigureRequestOption

type ConfigureRequestOption func(configuration *ConfigureRequestOptions)

ConfigureRequestOption an option that can be applied on a ConfigureRequestOptions

func AddProfiles

func AddProfiles(profileNames ...string) ConfigureRequestOption

AddProfiles adds a set of profiles to the configuration request

func AddValues

func AddValues(values map[string][]string) ConfigureRequestOption

AddValues adds a set of values in the configuration request

func SetRequestName

func SetRequestName(requestName string) ConfigureRequestOption

SetRequestName sets the named request in the configuration request

type ConfigureRequestOptions

type ConfigureRequestOptions struct {
	ProfileNames []string
	RequestName  string
	Values       map[string][]string
}

ConfigureRequestOptions set of options that can be used to configure a request

func CreateConfigureRequestOptions

func CreateConfigureRequestOptions(passedInOptions ...ConfigureRequestOption) *ConfigureRequestOptions

CreateConfigureRequestOptions creates the options to configure a request based on the options

func (*ConfigureRequestOptions) GetValues

func (config *ConfigureRequestOptions) GetValues() map[string][]string

GetValues returns the values from the configuration request

type ExecutedRequestResponse

type ExecutedRequestResponse struct {
	Request           Request
	Response          Response
	PostProcessError  string
	PostProcessOutput string
}

ExecutedRequestResponse represents a pair of request and the response that was returned from its execution. It also includes any output and/or error generated during post processing.

func ExecuteRequestLoop

func ExecuteRequestLoop(executionContext ExecutionContext) ([]ExecutedRequestResponse, error)

ExecuteRequestLoop executes HTTP requests based on the passed in options until there're no more requests to be executed.

type ExecutionContext

type ExecutionContext struct {
	AllowInsecure    bool
	FollowLocation   bool
	MaxAddedRequests int
	MaxRedirect      int
	ProfileNames     []string
	Request          Request
	Session          *session.Session
	Variables        map[string]string
}

ExecutionContext represent the options to be passed for the request executor.

type PostProcessContext

type PostProcessContext struct {
	Output   string
	Requests []Request
}

PostProcessContext stores

func PostProcess

func PostProcess(sourceCode PostProcessSourceCode, executionContext *ExecutionContext, executedRequests []ExecutedRequestResponse, responseErr error) (*PostProcessContext, error)

PostProcess processes the executed requests using the post processing script

type PostProcessSourceCode

type PostProcessSourceCode struct {
	// SourceCode is the code to be executed
	SourceCode string

	// SourceFilePath is the path to the file where the code came from
	SourceFilePath string
}

PostProcessSourceCode represents the source code to be executed

type Request

type Request struct {
	AllowInsecure   bool
	Body            string
	Cookies         []*http.Cookie
	Headers         map[string][]string
	Method          string
	PostProcessCode PostProcessSourceCode
	QueryParams     map[string][]string
	URL             string
}

Request stores data required to configure a request to be executed

func ConfigureRequest

func ConfigureRequest(unconfiguredRequest Request, mergedProfile *profile.Options, configureOptions *ConfigureRequestOptions) (*Request, error)

ConfigureRequest configures a request to be executed based on the provided options

func ConfigureRequestSimple

func ConfigureRequestSimple(unconfiguredRequest Request, mergedProfile *profile.Options, requestName string) (*Request, error)

ConfigureRequestSimple is a simpler version of configure request TODO - This was brute forced here to solve the post-processing issue, this code needs to be refactored

func (Request) GetAllowInsecure added in v1.2.0

func (req Request) GetAllowInsecure() bool

GetAllowInsecure returns if this named request allow insecure HTTP connections

func (Request) GetBody

func (req Request) GetBody() (string, error)

GetBody returns the body for this request

func (Request) GetHeaders

func (req Request) GetHeaders() map[string][]string

GetHeaders returns the headers for this request

func (Request) GetMethod

func (req Request) GetMethod() string

GetMethod returns the HTTP method for this request

func (*Request) LoadBodyFromFile

func (req *Request) LoadBodyFromFile(fileName string) error

LoadBodyFromFile loads data from a file and set it to the body, if not already set

func (*Request) Merge

func (req *Request) Merge(toMerge interface{}) error

Merge merges information from something compatible with a request into this request

func (*Request) MergeBody

func (req *Request) MergeBody(toMerge string)

MergeBody merges a body with this request

func (*Request) MergeHeaders

func (req *Request) MergeHeaders(headers map[string][]string)

MergeHeaders merges the passed headers into the request

func (*Request) MergeOptions

func (req *Request) MergeOptions(optionsToMerge profile.NamedRequest)

MergeOptions merges request options loaded from a profile

type Response

type Response struct {
	Body       string
	Headers    map[string][]string
	Protocol   string
	StatusCode int
	Status     string
}

Response is the response from the daemon after executing a request

Jump to

Keyboard shortcuts

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