v0.7.0 Latest Latest

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 17 Imported by: 5




This section is empty.


View Source
var BlockedHostnames = map[string]struct{}{
	"": {},
	"":   {},

BlockedHostnames constains hosts that blocked by sni detect.

View Source
var DefaultBypassSNIBlocking = os.Getenv("PIXIV_BYPASS_SNI_BLOCKING") != ""
View Source
var DefaultDNSQueryURL = os.Getenv("PIXIV_DNS_QUERY_URL")

DNSQueryURL is DNS over HTTPS service url that act like google public dns json api

View Source
var DefaultPHPSESSID = os.Getenv("PIXIV_PHPSESSID")
View Source
var DefaultUserAgent = os.Getenv("PIXIV_USER_AGENT")

DefaultUserAgent for new clients


func ParseAPIResult added in v0.2.0

func ParseAPIResult(r io.Reader) (ret gjson.Result, err error)

ParseAPIResult parses error from json api response, and returns body part.

func With added in v0.4.0

func With(ctx context.Context, v *Client) context.Context

With set client to context.


type BypassSNIBlockingTransport added in v0.3.2

type BypassSNIBlockingTransport struct {
	// contains filtered or unexported fields

BypassSNIBlockingTransport bypass sni bloking when host in BlockedHostnames

func (*BypassSNIBlockingTransport) RoundTrip added in v0.3.2

func (t *BypassSNIBlockingTransport) RoundTrip(req *http.Request) (resp *http.Response, err error)

RoundTrip implements http.RoundTripper

type Client added in v0.2.0

type Client struct {
	ServerURL   string
	DNSResolver dns.Resolver

Client to send request to pixiv server.

var Default *Client

Default client auto login with PIXIV_PHPSESSID env var.

func For added in v0.4.0

func For(ctx context.Context) *Client

For get client from context.

func NewDefaultClient added in v0.7.0

func NewDefaultClient() *Client

func (*Client) ApplyDefault added in v0.7.0

func (c *Client) ApplyDefault()

func (*Client) BypassSNIBlocking added in v0.3.2

func (c *Client) BypassSNIBlocking()

BypassSNIBlocking wrap current transport with bypass sni blocking support. must set before other settings, because it use a new http.Transport for blocked host

func (Client) EndpointURL added in v0.2.0

func (c Client) EndpointURL(path string, values *url.Values) *url.URL

EndpointURL returns url for server endpint.

func (*Client) GetWithContext added in v0.4.0

func (c *Client) GetWithContext(ctx context.Context, url string) (resp *http.Response, err error)

GetWithContext create get request with context and do it.

func (Client) IsLoggedIn added in v0.2.0

func (c Client) IsLoggedIn() (ret bool, err error)

IsLoggedIn checks login status base on `HEAD` response status.

func (*Client) Login added in v0.2.0

func (c *Client) Login(username string, password string) (err error)

Login with username and password

func (*Client) SetDefaultHeader added in v0.4.1

func (c *Client) SetDefaultHeader(key, value string)

SetDefaultHeader for all requests

func (*Client) SetPHPSESSID added in v0.2.0

func (c *Client) SetPHPSESSID(v string)

SetPHPSESSID set client cookie to skip login.

func (*Client) SetRequestOptions added in v0.4.1

func (c *Client) SetRequestOptions(options ...RequestOption)

SetRequestOptions for all requests

type RequestOption added in v0.4.1

type RequestOption = func(req *http.Request)

RequestOption can mutate request before actual send it.

type RequestOptionsTransport added in v0.4.1

type RequestOptionsTransport struct {
	// contains filtered or unexported fields

RequestOptionsTransport allow change request before do it.

func (*RequestOptionsTransport) RoundTrip added in v0.4.1

func (t *RequestOptionsTransport) RoundTrip(req *http.Request) (resp *http.Response, err error)

RoundTrip implements http.RoundTripper


Path Synopsis

Jump to

Keyboard shortcuts

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