Files
requests/README.md
2023-11-14 10:32:14 +08:00

4.6 KiB

Requests - A next-generation HTTP client for Golang.

Features

  • GET, POST, PUT, DELETE, HEAD, PATCH, OPTIONS, etc.
  • Simple for settings and request
  • Request Body can be string, []byte, struct, map, slice and io.Reader too
    • Auto detects Content-Type
    • Buffer less processing for io.Reader
    • Flow request
  • Response object gives you more possibility
  • Automatic marshal and unmarshal for content
  • Easy to upload one or more file(s) via multipart/form-data
    • Auto detects file content type
  • Request URL Path Params (aka URI Params)
  • Backoff Retry Mechanism with retry condition function
  • Optionally allows GET request with payload
  • Request design
    • Have client level settings & options and also override at Request level if you want to
    • Request and Response middleware
    • goroutine concurrent safe
    • Gzip - Go does it automatically also requests has fallback handling too
    • Works fine with HTTP/2 and HTTP/1.1
  • Session
  • IPv4, IPv6 Address Control Parsing
  • DNS Settings
  • Fingerprint
    • JA3
    • HTTP2
    • JA4
    • OrderHeaders
    • Request header capitalization
  • Proxy
    • HTTP
    • HTTPS
    • SOCKS5
  • Protocol
  • Well tested client library

Supported Go Versions

Recommended to use go1.21.3 and above. Initially Requests started supporting go modules

Installation

go get github.com/gospider007/requests

Usage

import "github.com/gospider007/requests"

Quickly send requests

package main

import (
	"log"
	"time"

	"github.com/gospider007/requests"
)

func main() {
    resp, err := requests.Get(nil, "http://httpbin.org/anything")
    if err != nil {
      log.Panic(err)
    }
    log.Print(resp.Text())    // Get content and parse as string
    log.Print(resp.Content()) // Get content as bytes
    log.Print(resp.Json())    // Get content and parse as gjson JSON
    log.Print(resp.Html())    // Get content and parse as goquery DOM
    log.Print(resp.Cookies()) // Get cookies
}

Contributing

If you have a bug report or feature request, you can open an issue

Contact

If you have questions, feel free to reach out to us in the following ways:

  • QQ Group (Chinese): 939111384 -
  • WeChat (Chinese): gospider007

Sponsors

If you like and it really helps you, feel free to reward me with a cup of coffee, and don't forget to mention your github id.


Wechat

Alipay