jhttp

package module
v0.0.0-...-daa74e6 Latest Latest
Warning

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

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

Documentation

Overview

*************************************************************************** MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************

*************************************************************************** MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************

*************************************************************************** MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************

*************************************************************************** MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************

*************************************************************************** MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownFile

func DownFile(url string, fname string, fpath string) error

download file

func Get

func Get(url string) (string, error)

func HttpGet

func HttpGet(url string, seconds int) (string, int, error)

func HttpPost

func HttpPost(url string, seconds int, contentType string, data string) (string, int, error)

func HttpPostJson

func HttpPostJson(url string, seconds int, data string) (string, int, error)

func Post

func Post(url string, t string, d string) (string, error)

func PostJson

func PostJson(url string, d string) (string, error)

func SaveFile

func SaveFile(file *multipart.FileHeader, path string, name string) (string, error)

保存文件

func UploadFile

func UploadFile(url string, timeout int32, filePath string) (string, error)

upload file to server,name is files

func UploadFileWithName

func UploadFileWithName(url string, timeout int32, filePath string, name string) (string, error)

upload file to server

func UploadFiles

func UploadFiles(url string, timeout int32, files []string, name string) (string, error)

upload files to url

func WebService11

func WebService11(url string, body string) (string, error)

/send a request of webservice /version 1.1

func WebService12

func WebService12(url string, body string) (string, error)

/send a request of webservice /version 1.2

Types

type Http

type Http struct {
	Client  *http.Client
	Error   string
	Request *http.Request
	// contains filtered or unexported fields
}

/Add By yjh 2021-06-17

func Create

func Create(url string, timeoutSecond int, way string) *Http

func CreateGET

func CreateGET(url string, timeoutSecond int) *Http

func CreatePOST

func CreatePOST(url string, timeoutSecond int) *Http

func CreatePOSTWithData

func CreatePOSTWithData(url string, timeoutSecond int, data string) *Http

func CreatePUT

func CreatePUT(url string, timeoutSecond int) *Http

func CreateWithData

func CreateWithData(url string, timeoutSecond int, way string, data string) *Http

func New

func New(url string, timeoutSecond int, way string) *Http

func NewWithData

func NewWithData(url string, timeoutSecond int, way string, data string) *Http

func (*Http) AddCookie

func (h *Http) AddCookie(name string, value string, path string, domain string) *Http

func (*Http) AddHeader

func (h *Http) AddHeader(name string, value string) *Http

func (*Http) HttpError

func (h *Http) HttpError() (bool, error)

func (*Http) Send

func (h *Http) Send() (string, int, error)

func (*Http) SendRequest

func (h *Http) SendRequest() (string, error)

func (*Http) SendRequestWithBody

func (h *Http) SendRequestWithBody() (string, int, error)

func (*Http) SendRequestWithResp

func (h *Http) SendRequestWithResp() (*HttpResp, error)

func (*Http) SendRequestWithoutBody

func (h *Http) SendRequestWithoutBody() (int, error)

func (*Http) SetHeader

func (h *Http) SetHeader(name string, value string) *Http

func (*Http) WithAccept

func (h *Http) WithAccept(v string) *Http

func (*Http) WithContentType

func (h *Http) WithContentType(v string) *Http

func (*Http) WithHeader

func (h *Http) WithHeader(name string, value string) *Http

func (*Http) WithJsonContentType

func (h *Http) WithJsonContentType() *Http

func (*Http) WithUserAgent

func (h *Http) WithUserAgent(v string) *Http

func (*Http) WithUserAgentDefault

func (h *Http) WithUserAgentDefault() *Http

type HttpResp

type HttpResp struct {
	Response *http.Response
}

/Add By yjh 2021-06-17

func (*HttpResp) Close

func (h *HttpResp) Close()

func (*HttpResp) GetCookie

func (h *HttpResp) GetCookie(name string) string

type HttpUA

type HttpUA struct {
	SysName []string
}

func NewUA

func NewUA() *HttpUA

func (*HttpUA) AddAgentSysName

func (h *HttpUA) AddAgentSysName(str string)

func (*HttpUA) RandChromeSysNameAndVerUA

func (h *HttpUA) RandChromeSysNameAndVerUA() string

func (*HttpUA) RandChromeVerUA

func (h *HttpUA) RandChromeVerUA() string

func (*HttpUA) RandEdgeSysNameAndVerUA

func (h *HttpUA) RandEdgeSysNameAndVerUA() string

func (*HttpUA) RandEdgeVerUA

func (h *HttpUA) RandEdgeVerUA() string

Jump to

Keyboard shortcuts

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