http

package
v1.0.83 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_DISCONECT    = "Perca de Conexão..."
	MSG_RECONECTANDO = "Reconectando..."
	MSG_RECONECTADO  = "Reconectado..."
	MSG_CONECTADO    = "Conectado..."
)

Variables

This section is empty.

Functions

func GeContentTypeStr

func GeContentTypeStr(value ContentType) string

func GetMethodStr

func GetMethodStr(value TMethod) string

func NewAuth2

func NewAuth2() *auth2

func NewProxy

func NewProxy() *proxy

Types

type AuthorizationType

type AuthorizationType int
const (
	AT_AutoDetect AuthorizationType = iota
	AT_Basic
	AT_Bearer
	AT_Auth2
	AT_Nenhum
)

type ClientAuth

type ClientAuth int
const (
	CA_SendBasicAuthHeader ClientAuth = iota
	CA_SendClientCredentialsInBody
)

type Content

type Content interface {
}

type ContentBinary

type ContentBinary struct {
	Name     string
	FileName string
	Value    []byte
}

type ContentFile

type ContentFile struct {
	Key         string
	FileName    string
	ContentType string
	Content     []byte
}

type ContentFormField

type ContentFormField struct {
	FieldName  string
	FieldValue string
}

type ContentText

type ContentText struct {
	Name  string
	Value *ST.Strings
}

type ContentType

type ContentType int
const (
	CT_NONE                  ContentType = 0
	CT_TEXT                  ContentType = 1
	CT_JAVASCRIPT            ContentType = 2
	CT_JSON                  ContentType = 3
	CT_HTML                  ContentType = 4
	CT_XML                   ContentType = 5
	CT_MULTIPART_FORM_DATA   ContentType = 6
	CT_X_WWW_FORM_URLENCODED ContentType = 7
	CT_BINARY                ContentType = 8
)

func GetContentTypeFromString

func GetContentTypeFromString(str string) ContentType

type EncType

type EncType int
const (
	ET_NONE                  EncType = 0
	ET_FORM_DATA             EncType = 1
	ET_X_WWW_FORM_URLENCODED EncType = 2
	ET_RAW                   EncType = 3
	ET_BINARY                EncType = 4
	ET_GRAPHQL               EncType = 5
	ET_WEB_SERVICE           EncType = 6
)

type Fields

type Fields map[string][]string

func NewFields

func NewFields() Fields

func (*Fields) Add

func (f *Fields) Add(fieldName string, fieldValue string)

func (*Fields) Clear

func (f *Fields) Clear()
type Header struct {
	Accept          string
	AcceptCharset   string
	AcceptEncoding  string
	AcceptLanguage  string
	Authorization   string
	Charset         string
	ContentType     string
	ContentLength   string
	ContentEncoding string
	ContentVersion  string
	ContentLocation string
	ExtraFields     Fields
}

func NewHeader

func NewHeader() *Header

func (*Header) AddField

func (H *Header) AddField(fieldName string, fieldValue string)

func (*Header) GetAllFields

func (H *Header) GetAllFields() map[string]string

type IWebsocket

type IWebsocket interface {
	Read(messageType int, body []byte, err error)
	Error(msg string)
	Msg(msg string)
	Disconect(msg string, limit bool)
}

type ListContentBinary

type ListContentBinary []*ContentBinary

func NewListContentBinary

func NewListContentBinary() ListContentBinary

func (*ListContentBinary) Add

func (L *ListContentBinary) Add(name string, fileName string, value []byte)

func (*ListContentBinary) Clear

func (L *ListContentBinary) Clear()

type ListContentFile

type ListContentFile []*ContentFile

func NewListContentFile

func NewListContentFile() ListContentFile

func (*ListContentFile) Add

func (L *ListContentFile) Add(key string, fileName string, contentType string, content []byte)

func (*ListContentFile) Clear

func (L *ListContentFile) Clear()

type ListContentFormField

type ListContentFormField []*ContentFormField

func NewListContentFormField

func NewListContentFormField() ListContentFormField

func (*ListContentFormField) Add

func (L *ListContentFormField) Add(fieldName string, fieldValue string)

func (*ListContentFormField) Clear

func (L *ListContentFormField) Clear()

type ListContentText

type ListContentText []*ContentText

func NewListContentText

func NewListContentText() ListContentText

func (*ListContentText) Add

func (L *ListContentText) Add(Name string, value *ST.Strings)

func (*ListContentText) Clear

func (L *ListContentText) Clear()

type Params

type Params map[string]string

func NewParams

func NewParams() Params

func (Params) Add

func (P Params) Add(key string, value string)

func (Params) Clear

func (P Params) Clear()

func (Params) Get

func (P Params) Get(key string) string

func (Params) Set

func (P Params) Set(key string, value string)

type Request

type Request struct {
	Header           *Header
	ItensFormField   ListContentFormField
	ItensSubmitFile  ListContentFile
	ItensContentText ListContentText
	ItensContentBin  ListContentBinary
	Body             []byte
}

func NewRequest

func NewRequest() *Request

func (*Request) AddContentBin

func (H *Request) AddContentBin(name string, filename string, value []byte)

func (*Request) AddContentText

func (H *Request) AddContentText(Name string, value *ST.Strings)

func (*Request) AddFormField

func (H *Request) AddFormField(fieldName string, fieldValue string)

func (*Request) AddSubmitFile

func (H *Request) AddSubmitFile(key string, filename string, contentType string, content []byte)

type Response

type Response struct {
	StatusCode    int
	StatusMessage string
	Body          []byte
	Header        map[string][]string
}

func NewResponse

func NewResponse() *Response

func (*Response) GetAllFields

func (R *Response) GetAllFields() map[string]string

func (*Response) GetBody

func (R *Response) GetBody() []byte

func (*Response) GetHeader

func (R *Response) GetHeader() map[string][]string

func (*Response) GetStatusCodeStr

func (R *Response) GetStatusCodeStr() string

func (*Response) GetStatusMessage

func (R *Response) GetStatusMessage() string

type Status added in v1.0.64

type Status int
const (
	OPEN Status = iota
	CLOSED
	CONNECTING
	STOP
)

type TCert added in v1.0.82

type TCert struct {
	PathCrt  string
	PathPriv string
}

type THttp

type THttp struct {

	/*publico*/
	Auth2             *auth2
	Request           *Request
	Response          *Response
	Metodo            TMethod
	AuthorizationType AuthorizationType
	WebSocket         *WebSocket
	Authorization     string
	Password          string
	UserName          string
	Certificate       TCert

	Protocolo string // http, https
	Host      string // www.example.com
	Path      string // /product
	Varibles  Varibles
	Params    Params
	Proxy     *proxy
	EncType   EncType
	Timeout   int //segundos
	OnSend    IWebsocket
	// contains filtered or unexported fields
}

func NewHttp

func NewHttp() *THttp

func (*THttp) Conectar

func (H *THttp) Conectar() error

func (*THttp) Desconectar

func (H *THttp) Desconectar() error

func (*THttp) EnviarBinario

func (H *THttp) EnviarBinario(messageType int, data []byte) error

func (*THttp) EnviarBinarioTypeBinaryMessage

func (H *THttp) EnviarBinarioTypeBinaryMessage(data []byte) error

func (*THttp) EnviarTextTypeTextMessage

func (H *THttp) EnviarTextTypeTextMessage(data []byte) error

func (*THttp) EnviarTexto

func (H *THttp) EnviarTexto(messageType int, data string) error

func (*THttp) GetAuthorizationType

func (H *THttp) GetAuthorizationType() AuthorizationType

func (*THttp) GetFullURL

func (H *THttp) GetFullURL() (string, error)

func (*THttp) GetMetodo

func (H *THttp) GetMetodo() TMethod

func (*THttp) GetMetodoStr

func (H *THttp) GetMetodoStr() string

func (*THttp) GetUrl

func (H *THttp) GetUrl() string

func (*THttp) IsConect

func (H *THttp) IsConect() bool

func (*THttp) Send

func (H *THttp) Send() (*Response, error)

func (*THttp) SetAuthorizationType

func (H *THttp) SetAuthorizationType(value AuthorizationType) error

func (*THttp) SetMetodo

func (H *THttp) SetMetodo(value TMethod) error

func (*THttp) SetMetodoStr

func (H *THttp) SetMetodoStr(value string) error

func (*THttp) SetUrl

func (H *THttp) SetUrl(value string) error

type TMethod

type TMethod int
const (
	M_GET     TMethod = 0
	M_POST    TMethod = 1
	M_PUT     TMethod = 2
	M_DELETE  TMethod = 3
	M_HEAD    TMethod = 4
	M_OPTIONS TMethod = 5
	M_TRACE   TMethod = 6
	M_PATCH   TMethod = 7
)

func GetStrFromMethod

func GetStrFromMethod(methodStr string) (TMethod, error)

type TokenResponse

type TokenResponse struct {
	AccessToken      string `json:"access_token"`
	ExpiresIn        int    `json:"expires_in"`
	RefreshExpiresIn int    `json:"refresh_expires_in"`
	TokenType        string `json:"token_type"`
	NotBeforePolicy  int    `json:"not-before-policy"`
	Scope            string `json:"scope"`
}

type Varibles

type Varibles map[string]string

func NewVaribles

func NewVaribles() Varibles

func (*Varibles) Add

func (v *Varibles) Add(key string, value string)

func (*Varibles) Clear

func (v *Varibles) Clear()

func (*Varibles) Count

func (v *Varibles) Count() int

func (*Varibles) Del

func (v *Varibles) Del(key string)

func (*Varibles) Exist

func (v *Varibles) Exist(key string) bool

func (*Varibles) Get

func (v *Varibles) Get(key string) string

func (*Varibles) Keys

func (v *Varibles) Keys() []string

func (*Varibles) Set

func (v *Varibles) Set(key string, value string)

func (*Varibles) ToMap

func (v *Varibles) ToMap() map[string]string

func (*Varibles) Values

func (v *Varibles) Values() []string

type WebSocket added in v1.0.61

type WebSocket struct {
	AutoReconnect    bool
	NumberOfAttempts int
	// contains filtered or unexported fields
}

func NewWebSocket added in v1.0.61

func NewWebSocket() *WebSocket

func (*WebSocket) Connect added in v1.0.64

func (ws *WebSocket) Connect() Status

type Writer added in v1.0.80

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

A Writer generates multipart messages.

func NewWriter added in v1.0.80

func NewWriter(w io.Writer) *Writer

NewWriter returns a new multipart Writer with a random boundary, writing to w.

func (*Writer) Boundary added in v1.0.80

func (w *Writer) Boundary() string

Boundary returns the Writer's boundary.

func (*Writer) Close added in v1.0.80

func (w *Writer) Close() error

Close finishes the multipart message and writes the trailing boundary end line to the output.

func (*Writer) CreateFormField added in v1.0.80

func (w *Writer) CreateFormField(fieldname string) (io.Writer, error)

CreateFormField calls CreatePart with a header using the given field name.

func (*Writer) CreateFormFile added in v1.0.80

func (w *Writer) CreateFormFile(fieldname string, filename string) (io.Writer, error)

CreateFormFile is a convenience wrapper around CreatePart. It creates a new form-data header with the provided field name and file name.

func (*Writer) CreateFormFile2 added in v1.0.80

func (w *Writer) CreateFormFile2(fieldname string, filename string, contenttype string) (io.Writer, error)

func (*Writer) CreatePart added in v1.0.80

func (w *Writer) CreatePart(header textproto.MIMEHeader) (io.Writer, error)

CreatePart creates a new multipart section with the provided header. The body of the part should be written to the returned Writer. After calling CreatePart, any previous part may no longer be written to.

func (*Writer) FormDataContentType added in v1.0.80

func (w *Writer) FormDataContentType() string

FormDataContentType returns the Content-Type for an HTTP multipart/form-data with this Writer's Boundary.

func (*Writer) SetBoundary added in v1.0.80

func (w *Writer) SetBoundary(boundary string) error

SetBoundary overrides the Writer's default randomly-generated boundary separator with an explicit value.

SetBoundary must be called before any parts are created, may only contain certain ASCII characters, and must be non-empty and at most 70 bytes long.

func (*Writer) WriteField added in v1.0.80

func (w *Writer) WriteField(fieldname, value string) error

WriteField calls CreateFormField and then writes the given value.

Jump to

Keyboard shortcuts

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