http

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 12 Imported by: 0

README

errors logo

go-net-http

A Go module for simplifying HTTP requests






Table of Contents

👁️ Overview

go-net-http is a Go module which can be utilized by applications to simplify HTTP requests, including requests using HTTP proxies. It includes logging through the use of the go-logger library.

Please review the module documentation for details on how to properly utilize it.

✅ Requirements

This module is supported for Go v1.14 and later.

📃 License

This module is distributed under the MIT License.

❓ Questions, Issues and Feature Requests

This project is not supported through the official Imperva Support channels. It is supported through the Imperva Technical Marketing Team on a best-effort basis. There are no warranties, SLAs or guarantees on support for this project.

If you have questions about this project, find a bug or wish to submit a feature request, please submit an issue.

Documentation

Overview

Package http handles interacting with HTTP clients and servers.

This package allows you to make HTTP requests through an HTTP proxy even those using an untrusted certificate (eg: signed by an internal CA).

Note that only HTTP Basic authentication is supported for proxy communication at this time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// ClientCertificates is a list of certificates to pass for client authentication.
	ClientCertificates []tls.Certificate

	// DisableSSLVerification disables HTTPS certificate verification when connecting to a server. You should
	// only do this if you are *really* sure. Otherwise, add the server's certificate to the RootCertificates
	// pool.
	DisableSSLVerification bool

	// RootCertificates is a pool of root CA certificates to trust.
	RootCertificates *crypto.CertificatePool
	// contains filtered or unexported fields
}

Client represents an HTTP client.

func NewClient

func NewClient(proxyConfig ProxyConfig) *Client

NewClient returns a new HTTP client object.

func (*Client) Delete

func (c *Client) Delete(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)

Delete performs a DELETE request for the given URL and returns the raw body byte array.

func (*Client) Get

func (c *Client) Get(url string, headers map[string]string) (*http.Response, []byte, error)

Get performs a GET request for the given URL and returns the raw body byte array.

func (*Client) NewRequest

func (c *Client) NewRequest(method, url string, body io.Reader) (*http.Client, *http.Request, error)

NewRequest creates a new HTTP request object using any configured proxy information.

Note that only HTTP Basic authentication is supported for proxied requests.

func (*Client) Options

func (c *Client) Options(url string, headers map[string]string) (*http.Response, []byte, error)

Options performs an OPTIONS request for the given URL and returns the raw body byte array.

func (*Client) Patch

func (c *Client) Patch(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)

Patch performs a PATCH request for the given URL and returns the raw body byte array.

func (*Client) Post

func (c *Client) Post(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)

Post performs a POST request for the given URL and returns the raw body byte array.

func (*Client) Put

func (c *Client) Put(url string, headers map[string]string, body []byte) (*http.Response, []byte, error)

Put performs a PUT request for the given URL and returns the raw body byte array.

type ProxyConfig

type ProxyConfig struct {
	httpproxy.Config

	// HTTPProxyUser is the username for proxy authentication for HTTP URLs.
	HTTPProxyUser string

	// HTTPProxyPass is the password for proxy authentication for HTTP URLs.
	HTTPProxyPass string

	// HTTPSProxyUser is the username for proxy authentication for HTTPS URLs.
	HTTPSProxyUser string

	// HTTPSProxyPass is the password for proxy authentication for HTTPS URLs.
	HTTPSProxyPass string
}

ProxyConfig holds the full configuration for proxy settings used by HTTP clients.

Jump to

Keyboard shortcuts

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