Class UpgradeRejection
The refused responses (HTTP 426, 401, 429 and the plan-limit 402) carry
{error:{code, message, requestId, details}}. Every field ends up on the server console,
so every field is untrusted and is kept only when it passes its own check: code,
reason and requestId keep [0-9A-Za-z._:-]{1,64}; minFramework
keeps [0-9A-Za-z.+-]{1,32}; message loses control and format characters and
colour codes and is cut to 200 characters; graceEndedAt keeps an ISO-8601 timestamp of
at most 40 characters; manageUrl keeps an https:// URL on ultikits.com
or one of its subdomains, at most 200 characters, without whitespace, control characters or
user information. Anything else becomes null.
parse(int, java.util.Map<java.lang.String, java.lang.String>, java.lang.String) never throws: a missing, partial, malformed or oversized body yields a value that
carries only the status (and the header-derived fields), and the status alone then decides what
the connection does. As in the frozen contract 2.0.0 (PROTOCOL.md section 10, plan 22-20, S-63),
every field is read from inside error only: a body without that wrapper is status-only,
and the plan-limit fields of a 402 (reason, graceEndedAt, manageUrl) are
read from error.details only, like the 426 details.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternprivate final Stringprivate static final Patternprivate final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate final String(package private) static final intLargest body that is parsed; the draft never hands over a larger one.private static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate final Stringprivate final Stringprivate final Stringprivate final Stringprivate final longprivate final intprivate static final Patternprivate static final Patternprivate static final Pattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Stringcode()(package private) String(package private) Stringprivate static String(package private) Stringmessage()private static String(package private) Stringprivate static com.google.gson.JsonObject(package private) static UpgradeRejectionParses a refused upgrade response.(package private) Stringprotocols(com.google.gson.JsonElement e) private static IntegerprotocolValue(String raw) private static voidreadBody(UpgradeRejection.Builder b, String body) private static voidreadHeaders(UpgradeRejection.Builder b, Map<String, String> headers) (package private) Stringprivate static longretryAfter(String raw) (package private) long(package private) intstatus()(package private) static UpgradeRejectionstatusOnly(int status) A value carrying only the status.private static Stringprivate static Stringprivate static StringtoString()private static String
-
Field Details
-
MAX_BODY_CHARS
static final int MAX_BODY_CHARSLargest body that is parsed; the draft never hands over a larger one.- See Also:
-
TOKEN
-
VERSION
-
TIMESTAMP
-
DIGITS
-
ANSI_SEQUENCE
-
MAX_TIMESTAMP_CHARS
private static final int MAX_TIMESTAMP_CHARS- See Also:
-
MAX_MESSAGE_CHARS
private static final int MAX_MESSAGE_CHARS- See Also:
-
MAX_URL_CHARS
private static final int MAX_URL_CHARS- See Also:
-
MAX_PROTOCOLS
private static final int MAX_PROTOCOLS- See Also:
-
MAX_PROTOCOL_VALUE
private static final int MAX_PROTOCOL_VALUE- See Also:
-
MANAGE_DOMAIN
- See Also:
-
HEADER_RETRY_AFTER
- See Also:
-
HEADER_PROTOCOL_SUPPORTED
- See Also:
-
status
private final int status -
code
-
message
-
requestId
-
minFramework
-
supportedProtocols
-
retryAfterSeconds
private final long retryAfterSeconds -
planReason
-
graceEndedAt
-
manageUrl
-
-
Constructor Details
-
UpgradeRejection
-
-
Method Details
-
statusOnly
A value carrying only the status.- Parameters:
status- the HTTP status of the upgrade response- Returns:
- the value
-
parse
Parses a refused upgrade response. Never throws.- Parameters:
status- the HTTP statusheadersLowerCase- the response headers, names lower-cased; may benullbodyOrNull- the complete body, ornullwhen it was absent, incomplete or too large- Returns:
- the sanitised value
-
readBody
-
readHeaders
-
retryAfter
-
object
-
string
-
protocols
-
protocolValue
-
token
-
version
-
timestamp
-
message
-
manageUrl
-
status
int status()- Returns:
- the HTTP status of the refused upgrade
-
code
String code()- Returns:
- the error code, or
null
-
message
String message()- Returns:
- the sanitised message, or
null
-
requestId
String requestId()- Returns:
- the request id, or
null
-
minFramework
String minFramework()- Returns:
- the minimum framework version the gateway accepts, or
null
-
supportedProtocols
- Returns:
- the protocol versions the gateway supports; empty when absent
-
retryAfterSeconds
long retryAfterSeconds()- Returns:
- the
Retry-Afterdelta in seconds, clamped, or -1 when absent or not delta-seconds
-
planReason
String planReason()- Returns:
- the plan-limit reason, or
null
-
graceEndedAt
String graceEndedAt()- Returns:
- when the plan-limit grace period ended, or
null
-
manageUrl
String manageUrl()- Returns:
- the panel page where the owner manages the plan, or
null
-
toString
-