status

package
v0.1.39 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

status.go This package provides utility functions and structures for handling and categorizing HTTP error responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNonRetryableStatusCode

func IsNonRetryableStatusCode(resp *http.Response) bool

IsNonRetryableStatusCode checks if the provided response indicates a non-retryable error.

func IsPermanentRedirect added in v0.0.97

func IsPermanentRedirect(statusCode int) bool

IsPermanentRedirect checks if the provided HTTP status code is one of the permanent redirect codes.

func IsRateLimitError

func IsRateLimitError(resp *http.Response) bool

IsRateLimitError checks if the provided response indicates a rate limit error.

func IsRedirectStatusCode added in v0.0.97

func IsRedirectStatusCode(statusCode int) bool

IsRedirectStatusCode checks if the provided HTTP status code is one of the redirect codes. Redirect status codes instruct the client to make a new request to a different URI, as defined in the response's Location header.

- 301 Moved Permanently: The requested resource has been assigned a new permanent URI and any future references to this resource should use one of the returned URIs. - 302 Found: The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client should continue to use the Request-URI for future requests. - 303 See Other: The response to the request can be found under a different URI and should be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. - 307 Temporary Redirect: The requested resource resides temporarily under a different URI. The client should not change the request method if it performs an automatic redirection to that URI. - 308 Permanent Redirect: The request and all future requests should be repeated using another URI. 308 parallel the behavior of 301 but do not allow the HTTP method to change. So, for example, submitting a form to a permanently redirected resource may continue smoothly.

The function returns true if the statusCode is one of the above redirect statuses, indicating that the client should follow the redirection as specified in the Location header of the response.

func IsRetryableStatusCode

func IsRetryableStatusCode(statusCode int) bool

IsRetryableStatusCode checks if the provided HTTP status code is considered retryable.

func IsTransientError

func IsTransientError(resp *http.Response) bool

IsTransientError checks if an error or HTTP response indicates a transient error.

func TranslateStatusCode

func TranslateStatusCode(resp *http.Response) string

TranslateStatusCode provides a human-readable message for HTTP status codes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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