cmn

package
v0.0.0-...-f6d4371 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package cmn common low-level types and utilities

  • Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.

Package cmn common low-level types and utilities

  • Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.

Package cmn common low-level types and utilities

  • Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.

Index

Constants

View Source
const (
	HeaderRange         = "Range" // Ref: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35
	HeaderContentLength = "Content-Length"
	HeaderContentType   = "Content-Type"
	HeaderContentRange  = "Content-Range"

	HeaderVersion    = "version"
	AwsHeaderVersion = "x-amz-version-id"

	GetContentType = "binary/octet-stream"
)

Variables

View Source
var (
	OverlapError = errors.New("failed to overlap")
)

Functions

func Assert

func Assert(cond bool, msg string)

func AssertNoErr

func AssertNoErr(err error)

func CopySection

func CopySection(r io.Reader, w io.Writer, start, length int64) (n int64, err error)

func ErrFileNotExists

func ErrFileNotExists(err error) bool

func Exit

func Exit(err error)

func InvalidMsgHandler

func InvalidMsgHandler(w http.ResponseWriter, errCode int, format string, a ...interface{})

func ObjectRange

func ObjectRange(rangeStr string, size int64) (rng *httpRange, err error)

func ParseMultiRange

func ParseMultiRange(s string, size int64) ([]httpRange, error)

From https://golang.org/src/net/http/fs.go ParseMultiRange parses a Range header string as per RFC 7233.

func SetResponseHeaders

func SetResponseHeaders(header http.Header, size int64, version string)

func WrapHttpError

func WrapHttpError(resp *http.Response, err error) (*http.Response, error)

Returns an error with message if status code was > 200

Types

type ByteHandle

type ByteHandle struct {
	*bytes.Reader
	// contains filtered or unexported fields
}

ByteHandle is a byte buffer(made from []byte) that implements ReadOpenCloser interface

func NewByteHandle

func NewByteHandle(bt []byte) *ByteHandle

func (*ByteHandle) Close

func (b *ByteHandle) Close() error

func (*ByteHandle) Open

func (b *ByteHandle) Open() (io.ReadCloser, error)

type OnCloseReader

type OnCloseReader struct {
	R  io.Reader
	Cb func()
}

func (*OnCloseReader) Close

func (r *OnCloseReader) Close()

func (*OnCloseReader) Read

func (r *OnCloseReader) Read(p []byte) (int, error)

type WriteCounter

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

func (*WriteCounter) Size

func (r *WriteCounter) Size() int64

func (*WriteCounter) Write

func (r *WriteCounter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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