Help us shape the future of Go! Take the 2026 Go Developer Survey

http

package
v1.537.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 22 Imported by: 51

Documentation

Index

Constants

View Source
const TrustStoreDirectory = ".pipeline/trustStore"

TrustStoreDirectory default truststore location

Variables

This section is empty.

Functions

func DownloadExecutable added in v1.230.0

func DownloadExecutable(githubToken string, fileUtils piperutils.FileUtils, downloader Downloader, url string) (string, error)

DownloadExecutable downloads a script or another executable and sets appropriate permissions

func ParseHTTPResponseBodyJSON added in v1.56.0

func ParseHTTPResponseBodyJSON(resp *http.Response, response any) error

ParseHTTPResponseBodyJSON parses a JSON http response into a given interface

func ParseHTTPResponseBodyXML added in v1.56.0

func ParseHTTPResponseBodyXML(resp *http.Response, response any) error

ParseHTTPResponseBodyXML parses an XML http response into a given interface

Types

type Client

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

Client defines an http client object

func (*Client) DownloadFile added in v1.14.0

func (c *Client) DownloadFile(url, filename string, header http.Header, cookies []*http.Cookie) error

DownloadFile downloads a file's content as GET request from the specified URL to the specified file

func (*Client) DownloadRequest added in v1.14.0

func (c *Client) DownloadRequest(method, url, filename string, header http.Header, cookies []*http.Cookie) error

DownloadRequest ...

func (*Client) GetRequest added in v1.180.0

func (c *Client) GetRequest(url string, header http.Header, cookies []*http.Cookie) (*http.Response, error)

GetRequest downloads content from a given URL and returns the response instead of writing it to file

func (*Client) Send added in v1.125.0

func (c *Client) Send(request *http.Request) (*http.Response, error)

Send sends a http request

func (*Client) SendRequest

func (c *Client) SendRequest(method, url string, body io.Reader, header http.Header, cookies []*http.Cookie) (*http.Response, error)

SendRequest sends a http request with a defined method

On error, any Response can be ignored and the Response.Body does not need to be closed.

func (*Client) SetFileUtils added in v1.207.0

func (c *Client) SetFileUtils(fileUtils piperutils.FileUtils)

SetFileUtils can be used to overwrite the default file utils

func (*Client) SetOptions

func (c *Client) SetOptions(options ClientOptions)

SetOptions sets options used for the http client

func (*Client) StandardClient added in v1.145.0

func (c *Client) StandardClient() *http.Client

StandardClient returns a stdlib *http.Client which respects the custom settings.

func (*Client) Upload added in v1.38.0

func (c *Client) Upload(data UploadRequestData) (*http.Response, error)

Upload uploads a file's content as multipart-form or pure binary with given http method request to the specified URL

func (*Client) UploadFile added in v1.9.0

func (c *Client) UploadFile(url, file, fileFieldName string, header http.Header, cookies []*http.Cookie, uploadType string) (*http.Response, error)

UploadFile uploads a file's content as multipart-form POST request to the specified URL

func (*Client) UploadRequest added in v1.10.0

func (c *Client) UploadRequest(method, url, file, fileFieldName string, header http.Header, cookies []*http.Cookie, uploadType string) (*http.Response, error)

UploadRequest uploads a file's content as multipart-form with given http method request to the specified URL

type ClientOptions

type ClientOptions struct {
	// MaxRequestDuration has a default value of "0", meaning "no maximum
	// request duration". If it is greater than 0, an overall, hard timeout
	// for the request will be enforced. This should only be used if the
	// length of the request bodies is known.
	MaxRequestDuration time.Duration
	MaxRetries         int
	// TransportTimeout defaults to 3 minutes, if not specified. It is
	// used for the transport layer and duration of handshakes and such.
	TransportTimeout          time.Duration
	TransportSkipVerification bool
	TransportProxy            *url.URL
	Username                  string
	Password                  string
	Token                     string
	Logger                    *logrus.Entry
	CookieJar                 http.CookieJar
	DoLogRequestBodyOnDebug   bool
	DoLogResponseBodyOnDebug  bool
	UseDefaultTransport       bool
	TrustedCerts              []string          // defines the set of root certificate authorities that clients use when verifying server certificates
	Certificates              []tls.Certificate // contains one or more certificate chains to present to the other side of the connection (client-authentication)
}

ClientOptions defines the options to be set on the client

type Downloader added in v1.14.0

type Downloader interface {
	SetOptions(options ClientOptions)
	DownloadFile(url, filename string, header http.Header, cookies []*http.Cookie) error
}

Downloader ...

type Sender

type Sender interface {
	SendRequest(method, url string, body io.Reader, header http.Header, cookies []*http.Cookie) (*http.Response, error)
	SetOptions(options ClientOptions)
}

Sender provides an interface to the piper http client for uid/pwd and token authenticated requests

type TransportWrapper added in v1.38.0

type TransportWrapper struct {
	Transport http.RoundTripper
	// contains filtered or unexported fields
}

TransportWrapper is a wrapper for central round trip capabilities

func (*TransportWrapper) RoundTrip added in v1.38.0

func (t *TransportWrapper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is the core part of this module and implements http.RoundTripper. Executes HTTP requests with request/response logging.

type UploadRequestData added in v1.38.0

type UploadRequestData struct {
	// Method is the HTTP method used for the request. Must be one of http.MethodPost or http.MethodPut.
	Method string
	// URL for the request
	URL string
	// File path to be stored in the created form field.
	File string
	// Form field name under which the file name will be stored.
	FileFieldName string
	// Additional form fields which will be added to the request if not nil.
	FormFields map[string]string
	// Reader from which the file contents will be read.
	FileContent io.Reader
	Header      http.Header
	Cookies     []*http.Cookie
	UploadType  string
}

UploadRequestData encapsulates the parameters for calling uploader.Upload()

type Uploader added in v1.9.0

type Uploader interface {
	Sender
	UploadRequest(method, url, file, fieldName string, header http.Header, cookies []*http.Cookie, uploadType string) (*http.Response, error)
	UploadFile(url, file, fieldName string, header http.Header, cookies []*http.Cookie, uploadType string) (*http.Response, error)
	Upload(data UploadRequestData) (*http.Response, error)
}

Uploader provides an interface to the piper http client for uid/pwd and token authenticated requests with upload capabilities

Jump to

Keyboard shortcuts

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