http

package
v0.0.0-...-5bb0c7b Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: MIT Imports: 19 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MIMEApplicationJSON                  = "application/json"
	MIMEApplicationJSONCharsetUTF8       = MIMEApplicationJSON + "; " + charsetUTF8
	MIMEApplicationJavaScript            = "application/javascript"
	MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8
	MIMEApplicationXML                   = "application/xml"
	MIMEApplicationXMLCharsetUTF8        = MIMEApplicationXML + "; " + charsetUTF8
	MIMETextXML                          = "text/xml"
	MIMETextXMLCharsetUTF8               = MIMETextXML + "; " + charsetUTF8
	MIMEApplicationForm                  = "application/x-www-form-urlencoded"
	MIMEApplicationProtobuf              = "application/protobuf"
	MIMEApplicationMsgpack               = "application/msgpack"
	MIMETextHTML                         = "text/html"
	MIMETextHTMLCharsetUTF8              = MIMETextHTML + "; " + charsetUTF8
	MIMETextPlain                        = "text/plain"
	MIMETextPlainCharsetUTF8             = MIMETextPlain + "; " + charsetUTF8
	MIMEMultipartForm                    = "multipart/form-data"
	MIMEOctetStream                      = "application/octet-stream"
	MIMEImagePNG                         = "image/png"
	MIMEImageJpeg                        = "image/jpeg"
	MIMEVideoMp4                         = "video/mp4"
)
View Source
const (
	ContentTypeApplicationJSON                  = "application/json"
	ContentTypeApplicationJSONCharsetUTF8       = ContentTypeApplicationJSON + "; " + charsetUTF8
	ContentTypeApplicationJavaScript            = "application/javascript"
	ContentTypeApplicationJavaScriptCharsetUTF8 = ContentTypeApplicationJavaScript + "; " + charsetUTF8
	ContentTypeApplicationXML                   = "application/xml"
	ContentTypeApplicationXMLCharsetUTF8        = ContentTypeApplicationXML + "; " + charsetUTF8
	ContentTypeTextXML                          = "text/xml"
	ContentTypeTextXMLCharsetUTF8               = ContentTypeTextXML + "; " + charsetUTF8
	ContentTypeApplicationForm                  = "application/x-www-form-urlencoded"
	ContentTypeApplicationProtobuf              = "application/protobuf"
	ContentTypeApplicationMsgpack               = "application/msgpack"
	ContentTypeTextHTML                         = "text/html"
	ContentTypeTextHTMLCharsetUTF8              = ContentTypeTextHTML + "; " + charsetUTF8
	ContentTypeTextPlain                        = "text/plain"
	ContentTypeTextPlainCharsetUTF8             = ContentTypeTextPlain + "; " + charsetUTF8
	ContentTypeMultipartForm                    = "multipart/form-data"
	ContentTypeOctetStream                      = "application/octet-stream"
	ContentTypeImagePNG                         = "image/png"
	ContentTypeImageJpeg                        = "image/jpeg"
	ContentTypeVideoMp4                         = "video/mp4"
	ContentTypeVideoWebm                        = "video/webm"
	ContentTypeVideoQuickTime                   = "video/quicktime"

	ContentTypeAudioMpeg = "audio/mpeg"
	ContentTypeAudioM4a  = "audio/m4a"
	ContentTypeAudioOgg  = "audio/ogg"
	ContentTypeAudioAmr  = "audio/amr"
	ContentTypeAudioWav  = "audio/x-wav"
)

Variables

This section is empty.

Functions

func AddURLQuery

func AddURLQuery(reqURL string, key, value string) string

func ContentTypeByUrl

func ContentTypeByUrl(httpUrl string) string

func DeleteDataWithHeaders

func DeleteDataWithHeaders(reqURL string, reqHeader goHttp.Header) (goHttp.Header, []byte, error)

func DownloadFile

func DownloadFile(reqURL string, filePath string) error

func GetData

func GetData(reqURL string) ([]byte, error)

func GetDataWithHeaders

func GetDataWithHeaders(reqURL string, reqHeader goHttp.Header) (goHttp.Header, []byte, error)

func GetJSON

func GetJSON(url string, out interface{}) error

func GetRequestBody

func GetRequestBody(r *http.Request) []byte

func GetRequestBodyAsMap

func GetRequestBodyAsMap(r *http.Request) map[string]interface{}

func PostData

func PostData(reqURL string, bodyType string, data []byte) ([]byte, error)

func PostDataSsl

func PostDataSsl(reqURL string, dataToSend, certPEMBlock, keyPEMBlock []byte) (respData []byte, err error)

func PostDataWithHeaders

func PostDataWithHeaders(reqURL string, reqHeader goHttp.Header, bodyType string, data []byte, timeout time.Duration) (goHttp.Header, []byte, error)

func PostFiles

func PostFiles(reqURL string, values map[string][]string, progressReporter func(r int64)) (ret []byte, err error)

func PostJSON

func PostJSON(reqURL string, objToSend interface{}, out interface{}) error

func PostXml

func PostXml(reqURL string, xmlToSend string, objReceived interface{}) (respData []byte, err error)

func PutDataWithHeaders

func PutDataWithHeaders(reqURL string, reqHeader goHttp.Header, bodyType string, data []byte) (goHttp.Header, []byte, error)

Types

type ProgressReader

type ProgressReader struct {
	bytes.Buffer
	Reporter func(r int64)
	// contains filtered or unexported fields
}

func (*ProgressReader) Read

func (pr *ProgressReader) Read(p []byte) (n int, err error)

func (*ProgressReader) Write

func (pr *ProgressReader) Write(p []byte) (n int, err error)

type UploadFile

type UploadFile struct {
	Name string
	Path string
	Data []byte
}

Jump to

Keyboard shortcuts

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