api

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoRequestWithBody added in v1.3.0

func DoRequestWithBody(
	ctx context.Context,
	client *http.Client,
	finalURL, httpMethod string,
	withBody bool,
	body io.Reader,
	bodyContentType string,
	effective_headers map[string]string,
) (_ *http.Response, rErr error)

DoRequestWithBody accepts an io.Reader for the request body instead of a fully-buffered []byte, so large payloads (e.g. a multipart body streamed from an io.Pipe) do not need to be materialized in memory before sending.

When body's length can't be determined by net/http (the common case for io.Pipe-based readers, since they aren't one of the special-cased *bytes.Buffer / *bytes.Reader / *strings.Reader types), http.NewRequestWithContext leaves Request.ContentLength at its zero value; per Request.outgoingLength, a non-nil Body combined with ContentLength == 0 is treated as "unknown length", so the Transport sends the request using chunked Transfer-Encoding. This also means Request.GetBody stays nil, so the Client cannot transparently retry the request body on redirects the way it can for a []byte-backed body — an inherent trade-off of streaming an unbuffered source.

Types

This section is empty.

Jump to

Keyboard shortcuts

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