http

package
v1.0.156 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_DISCONECT    = "Perca de Conexão..."
	MSG_RECONECTANDO = "Reconectando..."
	MSG_RECONECTADO  = "Reconectado..."
	MSG_CONECTADO    = "Conectado..."
)
View Source
const (
	// ContentTransferEncoding7Bit is the 7bit encoding
	ContentTransferEncodingNull = 0
	// ContentTransferEncoding7Bit is the 7bit encoding
	ContentTransferEncoding7Bit = 1
	// ContentTransferEncoding8Bit is the 8bit encoding
	ContentTransferEncoding8Bit = 2
	// ContentTransferEncodingBinary is the binary encoding
	ContentTransferEncodingBinary = 3
	// ContentTransferEncodingBase64 is the base64 encoding
	ContentTransferEncodingBase64 = 4
	// ContentTransferEncodingQuotedPrintable is the quoted-printable encoding
	ContentTransferEncodingQuotedPrintable = 5
)

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
	ContentTransferEncoding ContentTransferEncoding
	Content                 []byte
}

type ContentFormField

type ContentFormField struct {
	FieldName   string
	FieldValue  string
	ContentType string
}

type ContentText

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

type ContentTransferEncoding added in v1.0.91

type ContentTransferEncoding int

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
	CT_SOAPXML               ContentType = 9
	CT_PDF                   ContentType = 10
	CT_ZIP                   ContentType = 11
	CT_PNG                   ContentType = 12
	CT_JPEG                  ContentType = 13
	CT_GIF                   ContentType = 14
	CT_SVGXML                ContentType = 15
	CT_MPEG                  ContentType = 16
	CT_OGG                   ContentType = 17
	CT_MP4                   ContentType = 18
	CT_WEBM                  ContentType = 19
	CT_CSS                   ContentType = 20
	CT_CSV                   ContentType = 21
	CT_TSV                   ContentType = 22
	CT_YAML                  ContentType = 23
	CT_TAR                   ContentType = 24
	CT_RTF                   ContentType = 25
	CT_WAV                   ContentType = 26
	CT_FLAC                  ContentType = 27
	CT_AVI                   ContentType = 28
	CT_MOV                   ContentType = 29
	CT_BMP                   ContentType = 30
	CT_WEBP                  ContentType = 31
	CT_TIFF                  ContentType = 32
	CT_EOT                   ContentType = 33
	CT_TTF                   ContentType = 34
	CT_WOFF                  ContentType = 35
	CT_WOFF2                 ContentType = 36
)

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, transferEncoding ContentTransferEncoding)

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) AddContentType added in v1.0.86

func (L *ListContentFormField) AddContentType(fieldName string, fieldValue string, contentType 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) AddFormFieldContext added in v1.0.89

func (H *Request) AddFormFieldContext(fieldName string, fieldValue string, contentType string)

func (*Request) AddSubmitFile

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

func (*Request) AddSubmitFile2 added in v1.0.92

func (H *Request) AddSubmitFile2(key string, filename string, contentType string, content []byte, transferEncoding ContentTransferEncoding)

func (*Request) CopyBody added in v1.0.84

func (H *Request) CopyBody(value []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

func (*Response) GetToken added in v1.0.126

func (R *Response) GetToken() (string, error)

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
	CertPEMBlock []byte
	KeyPEMBlock  []byte
	PfxBlock     []byte
	PfxPass      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
	TransportType      TTransport
	InsecureSkipVerify bool // usado para TLS, se for true, ignora a verificação do certificado

	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) ConvertBodyInStruct added in v1.0.90

func (H *THttp) ConvertBodyInStruct(value any) 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) Free added in v1.0.115

func (H *THttp) Free()

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) GetProxyAtivo added in v1.0.132

func (H *THttp) GetProxyAtivo() bool

GetProxyAtivo verifica se o proxy está ativo

func (*THttp) GetProxyHost added in v1.0.132

func (H *THttp) GetProxyHost() string

GetProxyHost retorna o host do proxy

func (*THttp) GetProxyPassword added in v1.0.132

func (H *THttp) GetProxyPassword() string

GetProxyPassword retorna a senha do proxy

func (*THttp) GetProxyPort added in v1.0.132

func (H *THttp) GetProxyPort() int

GetProxyPort retorna a porta do proxy

func (*THttp) GetProxyUserName added in v1.0.132

func (H *THttp) GetProxyUserName() string

GetProxyUserName retorna o usuário do proxy

func (*THttp) GetTransport added in v1.0.132

func (H *THttp) GetTransport() *http.Transport

func (*THttp) GetUrl

func (H *THttp) GetUrl() string

func (*THttp) GetUrlFinal added in v1.0.110

func (H *THttp) GetUrlFinal() string

func (*THttp) IsConect

func (H *THttp) IsConect() bool

func (*THttp) LoadPfx added in v1.0.137

func (H *THttp) LoadPfx() (tls.Certificate, error)

func (*THttp) Send

func (H *THttp) Send() (RES *Response, err 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) SetProxyAtivo added in v1.0.132

func (H *THttp) SetProxyAtivo(ativo bool)

SetProxyAtivo ativa ou desativa o uso do proxy

func (*THttp) SetProxyConfig added in v1.0.132

func (H *THttp) SetProxyConfig(host string, port int, username, password string)

SetProxyConfig configura o proxy básico

func (*THttp) SetProxyHost added in v1.0.132

func (H *THttp) SetProxyHost(host string)

SetProxyHost define o host do proxy

func (*THttp) SetProxyPassword added in v1.0.132

func (H *THttp) SetProxyPassword(password string)

SetProxyPassword define a senha para autenticação no proxy

func (*THttp) SetProxyPort added in v1.0.132

func (H *THttp) SetProxyPort(port int)

SetProxyPort define a porta do proxy

func (*THttp) SetProxyUserName added in v1.0.132

func (H *THttp) SetProxyUserName(username string)

SetProxyUserName define o usuário para autenticação no proxy

func (*THttp) SetUrl

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

func (*THttp) UseCert added in v1.0.137

func (H *THttp) UseCert() bool

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 TTransport added in v1.0.131

type TTransport = int
const (
	TNenhum TTransport = 0
	TSSL    TTransport = 1
	TTLS    TTransport = 2
	TSSLTLS TTransport = 3
)

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) CreateFormFile3 added in v1.0.86

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

func (*Writer) CreateFormFile4 added in v1.0.91

func (w *Writer) CreateFormFile4(fieldname string, filename string, contenttype string, cte ContentTransferEncoding) (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