http

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LastModified       = "Last-Modified"
	Date               = "Date"
	ETag               = "ETag"
	ContentType        = "Content-Type"
	ContentMD5         = "Content-Md5"
	ContentEncoding    = "Content-Encoding"
	Expires            = "Expires"
	ContentLength      = "Content-Length"
	ContentLanguage    = "Content-Language"
	ContentRange       = "Content-Range"
	Connection         = "Connection"
	AcceptRanges       = "Accept-Ranges"
	AmzBucketRegion    = "X-Amz-Bucket-Region"
	ServerInfo         = "Server"
	RetryAfter         = "Retry-After"
	Location           = "Location"
	CacheControl       = "Cache-Control"
	ContentDisposition = "Content-Disposition"
	Authorization      = "Authorization"
	Action             = "Action"
	Range              = "Range"
)

Standard S3 HTTP response constants

View Source
const (
	XCache       = "X-Cache"
	XCacheLookup = "X-Cache-Lookup"
)

Non standard S3 HTTP response constants

View Source
const (
	IfModifiedSince   = "If-Modified-Since"
	IfUnmodifiedSince = "If-Unmodified-Since"
	IfMatch           = "If-Match"
	IfNoneMatch       = "If-None-Match"

	// S3 storage class
	AmzStorageClass = "x-amz-storage-class"

	// S3 object version ID
	AmzVersionID    = "x-amz-version-id"
	AmzDeleteMarker = "x-amz-delete-marker"

	// S3 object tagging
	AmzObjectTagging = "X-Amz-Tagging"
	AmzTagCount      = "x-amz-tagging-count"
	AmzTagDirective  = "X-Amz-Tagging-Directive"

	// S3 transition restore
	AmzRestore            = "x-amz-restore"
	AmzRestoreExpiryDays  = "X-Amz-Restore-Expiry-Days"
	AmzRestoreRequestDate = "X-Amz-Restore-Request-Date"
	AmzRestoreOutputPath  = "x-amz-restore-output-path"

	// S3 extensions
	AmzCopySourceIfModifiedSince   = "x-amz-copy-source-if-modified-since"
	AmzCopySourceIfUnmodifiedSince = "x-amz-copy-source-if-unmodified-since"

	AmzCopySourceIfNoneMatch = "x-amz-copy-source-if-none-match"
	AmzCopySourceIfMatch     = "x-amz-copy-source-if-match"

	AmzCopySource                 = "X-Amz-Copy-Source"
	AmzCopySourceVersionID        = "X-Amz-Copy-Source-Version-Id"
	AmzCopySourceRange            = "X-Amz-Copy-Source-Range"
	AmzMetadataDirective          = "X-Amz-Metadata-Directive"
	AmzObjectLockMode             = "X-Amz-Object-Lock-Mode"
	AmzObjectLockRetainUntilDate  = "X-Amz-Object-Lock-Retain-Until-Date"
	AmzObjectLockLegalHold        = "X-Amz-Object-Lock-Legal-Hold"
	AmzObjectLockBypassGovernance = "X-Amz-Bypass-Governance-Retention"
	AmzBucketReplicationStatus    = "X-Amz-Replication-Status"
	AmzSnowballExtract            = "X-Amz-Meta-Snowball-Auto-Extract"

	// Multipart parts count
	AmzMpPartsCount = "x-amz-mp-parts-count"

	// Object date/time of expiration
	AmzExpiration = "x-amz-expiration"

	// Dummy putBucketACL
	AmzACL = "x-amz-acl"

	// Signature V4 related contants.
	AmzContentSha256        = "X-Amz-Content-Sha256"
	AmzDate                 = "X-Amz-Date"
	AmzAlgorithm            = "X-Amz-Algorithm"
	AmzExpires              = "X-Amz-Expires"
	AmzSignedHeaders        = "X-Amz-SignedHeaders"
	AmzSignature            = "X-Amz-Signature"
	AmzCredential           = "X-Amz-Credential"
	AmzSecurityToken        = "X-Amz-Security-Token"
	AmzDecodedContentLength = "X-Amz-Decoded-Content-Length"

	AmzMetaUnencryptedContentLength = "X-Amz-Meta-X-Amz-Unencrypted-Content-Length"
	AmzMetaUnencryptedContentMD5    = "X-Amz-Meta-X-Amz-Unencrypted-Content-Md5"

	// AWS server-side encryption headers for SSE-S3, SSE-KMS and SSE-C.
	AmzServerSideEncryption                      = "X-Amz-Server-Side-Encryption"
	AmzServerSideEncryptionKmsID                 = AmzServerSideEncryption + "-Aws-Kms-Key-Id"
	AmzServerSideEncryptionKmsContext            = AmzServerSideEncryption + "-Context"
	AmzServerSideEncryptionCustomerAlgorithm     = AmzServerSideEncryption + "-Customer-Algorithm"
	AmzServerSideEncryptionCustomerKey           = AmzServerSideEncryption + "-Customer-Key"
	AmzServerSideEncryptionCustomerKeyMD5        = AmzServerSideEncryption + "-Customer-Key-Md5"
	AmzServerSideEncryptionCopyCustomerAlgorithm = "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Algorithm"
	AmzServerSideEncryptionCopyCustomerKey       = "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key"
	AmzServerSideEncryptionCopyCustomerKeyMD5    = "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key-Md5"

	AmzEncryptionAES = "AES256"
	AmzEncryptionKMS = "aws:kms"

	// Signature v2 related constants
	AmzSignatureV2 = "Signature"
	AmzAccessKeyID = "AWSAccessKeyId"

	// Response request id.
	AmzRequestID = "x-amz-request-id"

	// Deployment id.
	MinioDeploymentID = "x-minio-deployment-id"

	// Server-Status
	MinIOServerStatus = "x-minio-server-status"

	// Delete special flag to force delete a bucket
	MinIOForceDelete = "x-minio-force-delete"

	// Header indicates if the mtime should be preserved by client
	MinIOSourceMTime = "x-minio-source-mtime"

	// Header indicates if the etag should be preserved by client
	MinIOSourceETag = "x-minio-source-etag"

	// Writes expected write quorum
	MinIOWriteQuorum = "x-minio-write-quorum"

	// Reports number of drives currently healing
	MinIOHealingDrives = "x-minio-healing-drives"

	// Header indicates if the delete marker should be preserved by client
	MinIOSourceDeleteMarker = "x-minio-source-deletemarker"

	// Header indicates if the delete marker version needs to be purged.
	MinIOSourceDeleteMarkerDelete = "x-minio-source-deletemarker-delete"

	// Header indicates permanent delete replication status.
	MinIODeleteReplicationStatus = "X-Minio-Replication-Delete-Status"
	// Header indicates delete-marker replication status.
	MinIODeleteMarkerReplicationStatus = "X-Minio-Replication-DeleteMarker-Status"
	// Header indicates if its a GET/HEAD proxy request for active-active replication
	MinIOSourceProxyRequest = "X-Minio-Source-Proxy-Request"
	// Header indicates that this request is a replication request to create a REPLICA
	MinIOSourceReplicationRequest = "X-Minio-Source-Replication-Request"
	// Header indicates replication reset status.
	MinIOReplicationResetStatus = "X-Minio-Replication-Reset-Status"

	// predicted date/time of transition
	MinIOTransition = "X-Minio-Transition"
)

Standard S3 HTTP request constants

View Source
const (
	VersionID = "versionId"

	PartNumber = "partNumber"

	UploadID = "uploadId"
)

Common http query params S3 API

View Source
const (

	// DefaultShutdownTimeout - default shutdown timeout used for graceful http server shutdown.
	DefaultShutdownTimeout = 5 * time.Second

	// DefaultMaxHeaderBytes - default maximum HTTP header size in bytes.
	DefaultMaxHeaderBytes = 1 * humanize.MiByte
)

Variables

This section is empty.

Functions

func DrainBody

func DrainBody(respBody io.ReadCloser)

DrainBody close non nil response with any response Body. convenient wrapper to drain any remaining data on response body.

Subsequently this allows golang http RoundTripper to re-use the same connection for future requests.

Types

type DNSCache

type DNSCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DNSCache is DNS cache resolver which cache DNS resolve results in memory.

func NewDNSCache

func NewDNSCache(freq time.Duration, lookupTimeout time.Duration, loggerOnce func(ctx context.Context, err error, id interface{}, errKind ...interface{})) *DNSCache

NewDNSCache initializes DNS cache resolver and starts auto refreshing in a new goroutine. To stop auto refreshing, call `Stop()` function. Once `Stop()` is called auto refreshing cannot be resumed.

func (*DNSCache) Fetch

func (r *DNSCache) Fetch(ctx context.Context, host string) ([]string, error)

Fetch fetches IP list from the cache. If IP list of the given addr is not in the cache, then it lookups from DNS server by `Lookup` function.

func (*DNSCache) LookupHost

func (r *DNSCache) LookupHost(ctx context.Context, host string) ([]string, error)

LookupHost lookups address list from DNS server, persist the results in-memory cache. `Fetch` is used to obtain the values for a given host.

func (*DNSCache) Refresh

func (r *DNSCache) Refresh()

Refresh refreshes IP list cache, automatically.

func (*DNSCache) Stop

func (r *DNSCache) Stop()

Stop stops auto refreshing.

type DialContext

type DialContext func(ctx context.Context, network, address string) (net.Conn, error)

DialContext is a function to make custom Dial for internode communications

func DialContextWithDNSCache

func DialContextWithDNSCache(cache *DNSCache, baseDialCtx DialContext) DialContext

DialContextWithDNSCache is a helper function which returns `net.DialContext` function. It randomly fetches an IP from the DNS cache and dials it by the given dial function. It dials one by one and returns first connected `net.Conn`. If it fails to dial all IPs from cache it returns first error. If no baseDialFunc is given, it sets default dial function.

You can use returned dial function for `http.Transport.DialContext`.

In this function, it uses functions from `rand` package. To make it really random, you MUST call `rand.Seed` and change the value from the default in your application

func NewCustomDialContext

func NewCustomDialContext(dialTimeout time.Duration) DialContext

NewCustomDialContext setups a custom dialer for any external communication and proxies.

func NewInternodeDialContext

func NewInternodeDialContext(dialTimeout time.Duration) DialContext

NewInternodeDialContext setups a custom dialer for internode communication

type Server

type Server struct {
	http.Server
	Addrs           []string      // addresses on which the server listens for new connection.
	ShutdownTimeout time.Duration // timeout used for graceful server shutdown.
	// contains filtered or unexported fields
}

Server - extended http.Server supports multiple addresses to serve and enhanced connection handling.

func NewServer

func NewServer(addrs []string, handler http.Handler, getCert certs.GetCertificateFunc) *Server

NewServer - creates new HTTP server using given arguments.

func (*Server) GetRequestCount

func (srv *Server) GetRequestCount() int

GetRequestCount - returns number of request in progress.

func (*Server) Shutdown

func (srv *Server) Shutdown() error

Shutdown - shuts down HTTP server.

func (*Server) Start

func (srv *Server) Start() (err error)

Start - start HTTP server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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