gokhttp

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 3 Imported by: 3

README

Golang HTTP Client

Go Report Card License

Introduction

gOkHttp is HTTP Client written in Golang inspired by Java's (now Kotlin's) OkHTTP and also slightly inspired by Python's Requests.

This library has been written with handling cookies (in-memory, on-disk, encrypted on-disk), headers, parameters, post fields, post multipart bodies, post files and SSL pinning in mind.

  • Inspired by okhttp
    • SSL Pinning implementation and ease of using it
  • Inspired by requests
    • Response processing (eg: responses.ResponseText(httpResp) to return response body as a string)
    • Making requests with headers and parameters as maps (there where in Python it's dicts)
Features

This library has the following features in its ecosystem:

  • Easy client construction
  • Easy request construction
  • Easy response parsing
  • HTML parsing (and soon other advanced formats) with goquery found here
  • Cookie handling (in-memory, on-disk, encrypted on-disk) found here
  • SSL Pinning found here
  • HTTP3 client support (theoretical) found here
  • Easy to use downloader implementations (multi-threaded, HLS stream downloader) found here
  • JA3 fingerprint spoofing found here
Why are some features split into another repository?

In order to keep the main library lightweight I needed these dependencies to be optional, if you need them you can import them as-needed. This will result in smaller binary sizes and fewer dependencies to scan for licensing issues.

Warning

This library is a lot more stable than it was back when I first wrote it, though it's far from perfect so do not use it for mission critical stuff

Installation

The package can be installed using "go get".

go get -u github.com/BRUHItsABunny/gOkHttp

Usage

There is a file filled with examples here, and you can find the Go docs here

NOTE for HLS streams

If the .ts file is broken, run it through FFmpeg in order to fix it real quick: ffmpeg -i file.ts -c copy file_fixed.ts

Contributions

Feel free to fork this repository and open up pull requests.

Todo

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient added in v0.0.7

func NewHTTPClient(options ...gokhttp_client.Option) (*http.Client, error)
Example

This function makes a basic `*http.Client` object

hClient, err := NewHTTPClient()
if err != nil {
	panic(err)
}
// Just to prevent unused error in IDE
fmt.Println(hClient)
Output:

func TestHTTPClient added in v0.2.4

func TestHTTPClient(options ...gokhttp_client.Option) (*http.Client, error)

TestHTTPClient is a function i end up using a lot in test files to control how my http.Client is initialized depending on the ENV variables USE_PROXY and PROXY_URL

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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