Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions client/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,34 @@ type Status struct {
Reason string
}

func (s Status) String() string {
return fmt.Sprintf("%d %s", s.Code, s.Reason)
}

func (s Status) IsInformational() bool {
return s.Code >= INFO_CONTINUE && s.Code < SUCCESS_OK
}

func (s Status) String() string { return fmt.Sprintf("%d %s", s.Code, s.Reason) }
func (s Status) IsSuccess() bool {
return s.Code >= SUCCESS_OK && s.Code < REDIRECTION_MULTIPLE_CHOICES
}

func (s Status) IsInformational() bool { return s.Code >= INFO_CONTINUE && s.Code < SUCCESS_OK }
func (s Status) IsSuccess() bool { return s.Code >= SUCCESS_OK && s.Code < REDIRECTION_MULTIPLE_CHOICES }
func (s Status) IsRedirect() bool {
// Per RFC 9110 section 15.4.5 a 304 response is terminated by the end of the header section and it refers to a local resource.
// No further requests are supposed to be issued after a 304 response is received.
if s.Code == REDIRECTION_NOT_MODIFIED {
return false
}
return s.Code >= REDIRECTION_MULTIPLE_CHOICES && s.Code < CLIENT_ERROR_BAD_REQUEST
}
func (s Status) IsError() bool { return s.Code >= CLIENT_ERROR_BAD_REQUEST }
func (s Status) IsError() bool {
return s.Code >= CLIENT_ERROR_BAD_REQUEST
}

func (s Status) IsClientError() bool {
return s.Code >= CLIENT_ERROR_BAD_REQUEST && s.Code < SERVER_ERROR_INTERNAL
}
func (s Status) IsServerError() bool { return s.Code >= SERVER_ERROR_INTERNAL }

func (s Status) IsServerError() bool {
return s.Code >= SERVER_ERROR_INTERNAL
}