bce-sdk-go: github.com/baidubce/bce-sdk-go/http Index | Files

package http

import "github.com/baidubce/bce-sdk-go/http"

Package http defines the structure of request and response which used to access the BCE services as well as the http constant headers and and methods. And finally implement the `Execute` funct- ion to do the work.

Index

Package Files

client.go constants.go request.go response.go

Constants

const (
    GET    = "GET"
    PUT    = "PUT"
    POST   = "POST"
    DELETE = "DELETE"
    HEAD   = "HEAD"
)

Constants of the supported HTTP methods for BCE

const (
    // Standard HTTP Headers
    AUTHORIZATION       = "Authorization"
    CACHE_CONTROL       = "Cache-Control"
    CONTENT_DISPOSITION = "Content-Disposition"
    CONTENT_ENCODING    = "Content-Encoding"
    CONTENT_LANGUAGE    = "Content-Language"
    CONTENT_LENGTH      = "Content-Length"
    CONTENT_MD5         = "Content-Md5"
    CONTENT_RANGE       = "Content-Range"
    CONTENT_TYPE        = "Content-Type"
    DATE                = "Date"
    ETAG                = "Etag"
    EXPIRES             = "Expires"
    HOST                = "Host"
    LAST_MODIFIED       = "Last-Modified"
    LOCATION            = "Location"
    RANGE               = "Range"
    SERVER              = "Server"
    TRANSFER_ENCODING   = "Transfer-Encoding"
    USER_AGENT          = "User-Agent"

    // BCE Common HTTP Headers
    BCE_PREFIX               = "x-bce-"
    BCE_ACL                  = "x-bce-acl"
    BCE_GRANT_READ           = "x-bce-grant-read"
    BCE_GRANT_FULL_CONTROL   = "x-bce-grant-full-control"
    BCE_CONTENT_SHA256       = "x-bce-content-sha256"
    BCE_CONTENT_CRC32        = "x-bce-content-crc32"
    BCE_REQUEST_ID           = "x-bce-request-id"
    BCE_USER_METADATA_PREFIX = "x-bce-meta-"
    BCE_SECURITY_TOKEN       = "x-bce-security-token"
    BCE_DATE                 = "x-bce-date"

    // BOS HTTP Headers
    BCE_COPY_METADATA_DIRECTIVE         = "x-bce-metadata-directive"
    BCE_COPY_SOURCE                     = "x-bce-copy-source"
    BCE_COPY_SOURCE_IF_MATCH            = "x-bce-copy-source-if-match"
    BCE_COPY_SOURCE_IF_MODIFIED_SINCE   = "x-bce-copy-source-if-modified-since"
    BCE_COPY_SOURCE_IF_NONE_MATCH       = "x-bce-copy-source-if-none-match"
    BCE_COPY_SOURCE_IF_UNMODIFIED_SINCE = "x-bce-copy-source-if-unmodified-since"
    BCE_COPY_SOURCE_RANGE               = "x-bce-copy-source-range"
    BCE_DEBUG_ID                        = "x-bce-debug-id"
    BCE_OBJECT_TYPE                     = "x-bce-object-type"
    BCE_NEXT_APPEND_OFFSET              = "x-bce-next-append-offset"
    BCE_STORAGE_CLASS                   = "x-bce-storage-class"
    BCE_PROCESS                         = "x-bce-process"
    BCE_RESTORE_TIER                    = "x-bce-restore-tier"
    BCE_RESTORE_DAYS                    = "x-bce-restore-days"
)

Constants of the HTTP headers for BCE

type Request Uses

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

Reauest stands for the general http request structure to make request to the BCE services.

func (*Request) Body Uses

func (r *Request) Body() io.ReadCloser

func (*Request) Endpoint Uses

func (r *Request) Endpoint() string

func (*Request) GenerateUrl Uses

func (r *Request) GenerateUrl(addPort bool) string

func (*Request) Header Uses

func (r *Request) Header(key string) string

func (*Request) Headers Uses

func (r *Request) Headers() map[string]string

func (*Request) Host Uses

func (r *Request) Host() string

func (*Request) Length Uses

func (r *Request) Length() int64

func (*Request) Method Uses

func (r *Request) Method() string

func (*Request) Param Uses

func (r *Request) Param(key string) string

func (*Request) Params Uses

func (r *Request) Params() map[string]string

func (*Request) Port Uses

func (r *Request) Port() int

func (*Request) Protocol Uses

func (r *Request) Protocol() string

func (*Request) ProxyUrl Uses

func (r *Request) ProxyUrl() string

func (*Request) QueryString Uses

func (r *Request) QueryString() string

func (*Request) SetBody Uses

func (r *Request) SetBody(stream io.ReadCloser)

func (*Request) SetEndpoint Uses

func (r *Request) SetEndpoint(endpoint string)

func (*Request) SetHeader Uses

func (r *Request) SetHeader(key, value string)

func (*Request) SetHeaders Uses

func (r *Request) SetHeaders(headers map[string]string)

func (*Request) SetHost Uses

func (r *Request) SetHost(host string)

func (*Request) SetLength Uses

func (r *Request) SetLength(l int64)

func (*Request) SetMethod Uses

func (r *Request) SetMethod(method string)

func (*Request) SetParam Uses

func (r *Request) SetParam(key, value string)

func (*Request) SetParams Uses

func (r *Request) SetParams(params map[string]string)

func (*Request) SetPort Uses

func (r *Request) SetPort(port int)

func (*Request) SetProtocol Uses

func (r *Request) SetProtocol(protocol string)

func (*Request) SetProxyUrl Uses

func (r *Request) SetProxyUrl(url string)

func (*Request) SetTimeout Uses

func (r *Request) SetTimeout(timeout int)

func (*Request) SetUri Uses

func (r *Request) SetUri(uri string)

func (*Request) String Uses

func (r *Request) String() string

func (*Request) Timeout Uses

func (r *Request) Timeout() int

func (*Request) Uri Uses

func (r *Request) Uri() string

type Response Uses

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

Response defines the general http response structure for accessing the BCE services.

func Execute Uses

func Execute(request *Request) (*Response, error)

Execute - do the http requset and get the response

PARAMS:

- request: the http request instance to be sent

RETURNS:

- response: the http response returned from the server
- error: nil if ok otherwise the specific error

func (*Response) Body Uses

func (r *Response) Body() io.ReadCloser

func (*Response) ContentLength Uses

func (r *Response) ContentLength() int64

func (*Response) ElapsedTime Uses

func (r *Response) ElapsedTime() time.Duration

func (*Response) GetHeader Uses

func (r *Response) GetHeader(name string) string

func (*Response) GetHeaders Uses

func (r *Response) GetHeaders() map[string]string

func (*Response) HttpResponse Uses

func (r *Response) HttpResponse() *http.Response

func (*Response) Protocol Uses

func (r *Response) Protocol() string

func (*Response) SetHttpResponse Uses

func (r *Response) SetHttpResponse(response *http.Response)

func (*Response) StatusCode Uses

func (r *Response) StatusCode() int

func (*Response) StatusText Uses

func (r *Response) StatusText() string

Package http imports 9 packages (graph) and is imported by 16 packages. Updated 2020-04-04. Refresh now. Tools for package owners.