v3go.etcd.io/etcd/pkg/v3/httputil Index | Files

package httputil

import "go.etcd.io/etcd/pkg/v3/httputil"

Package httputil provides HTTP utility functions.

Index

Functions

func GetHostname

func GetHostname(req *http.Request) string

GetHostname returns the hostname from request Host field. It returns empty string, if Host field contains invalid value (e.g. "localhost:::" with too many colons).

func GracefulClose

func GracefulClose(resp *http.Response)

GracefulClose drains http.Response.Body until it hits EOF and closes it. This prevents TCP/TLS connections from closing, therefore available for reuse. Borrowed from golang/net/context/ctxhttp/cancelreq.go.

Source Files

httputil.go

Version
v3.6.1 (latest)
Published
Jun 6, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
1 week ago

Tools for package owners.