11/************************************************
2- Copyright (c) 2015-2016 by Progress Software Corporation. All rights reserved.
3- ************************************************ */
2+ Copyright (c) 2015-2016,2026 by Progress Software Corporation. All rights reserved.
3+ ************************************************ */
44/*------------------------------------------------------------------------
55 File : StatusCodeHelper
6- Purpose : Helps to convert/find default values for status codes and
7- their messages
8- Syntax :
9- Description :
6+ Purpose : Helps to convert/find default values for status codes and
7+ their messages; effectively the inverse of StatusCodeEnum
8+ Description :
109 Author(s) : pjudge
1110 Created : Wed Sep 16 10:57:44 EDT 2015
12- Notes :
11+ Notes :
1312 ---------------------------------------------------------------------- */
1413block-level on error undo , throw .
1514
1615using OpenEdge.Net.HTTP.StatusCodeEnum .
1716using OpenEdge.Core.Assert .
1817
1918class OpenEdge.Net.HTTP.StatusCodeHelper :
20-
19+
2120 /* Returns the default status message for a status code.
22-
21+
2322 @param integer The status code to convert.
2423 @return character The (default) status code text. */
2524 method public static character GetMessage (input piStatusCode as integer ):
2625 define variable oStatusCode as StatusCodeEnum no-undo .
27-
26+
2827 assign oStatusCode = StatusCodeEnum :GetEnum (piStatusCode ) no-error .
29-
28+
3029 return GetMessage (oStatusCode ).
3130 end method .
32-
31+
3332 /* Returns the default status message for a status code.
34-
33+
3534 @param StatusCodeEnum The status code to convert.
3635 @return character The (default) status code text. */
3736 method public static character GetMessage (input poStatusCode as StatusCodeEnum ):
@@ -40,21 +39,24 @@ class OpenEdge.Net.HTTP.StatusCodeHelper:
4039 else
4140 case poStatusCode :
4241 /* 1xx */
43- when StatusCodeEnum :SwitchingProtocols then return 'Switching Protocols' :u .
42+ when StatusCodeEnum :SwitchingProtocols then return 'Switching Protocols' :u .
43+ when StatusCodeEnum :EarlyHints then return 'Early Hints' :u .
44+ // TEMPORARY, Draft Spec: https://httpwg.org/http-extensions/draft-ietf-httpbis-resumable-upload.html
45+ when StatusCodeEnum :UploadResumptionSupported then return 'Upload Resumption Supported' :u .
4446 /* 2xx */
4547 when StatusCodeEnum :NonAuthoritativeInformation then return 'Non Authoritative Information' :u .
4648 when StatusCodeEnum :NoContent then return 'No Content' :u .
4749 when StatusCodeEnum :ResetContent then return 'Reset Content' :u .
4850 when StatusCodeEnum :PartialContent then return 'Partial Content' :u .
4951 when StatusCodeEnum :AlreadyReported then return 'Already Reported' :u .
5052 when StatusCodeEnum :IMUsed then return 'IM Used' :u .
51-
53+
5254 /* 3xx */
5355 when StatusCodeEnum :MultipleChoices then return 'Multiple Choices' :u .
5456 when StatusCodeEnum :MovedPermanently then return 'Moved Permanently' :u .
5557 when StatusCodeEnum :SeeOther then return 'See Other' :u .
5658 when StatusCodeEnum :NotModified then return 'Not Modified' :u .
57- when StatusCodeEnum :UseProxy then return 'Use Proxy' :u .
59+ when StatusCodeEnum :UseProxy then return 'Use Proxy' :u . // DEPRECATED in RFC 9110. Maintained for backward compatibility only.
5860 when StatusCodeEnum :TemporaryRedirect then return 'Temporary Redirect' :u .
5961 when StatusCodeEnum :PermanentRedirect then return 'Permanent Redirect' :u .
6062
@@ -73,13 +75,16 @@ class OpenEdge.Net.HTTP.StatusCodeHelper:
7375 when StatusCodeEnum :UnsupportedMediaType then return 'Unsupported Media Type' :u .
7476 when StatusCodeEnum :RequestedRangeNotSatisfiable then return 'Requested Range Not Satisfiable' :u .
7577 when StatusCodeEnum :ExpectationFailed then return 'Expectation Failed' :u .
76- when StatusCodeEnum :MisdirectedRequest then return 'Misdirected Request' :u .
77- when StatusCodeEnum :UnprocessableEntity then return 'Unprocessable Entity' :u .
78- when StatusCodeEnum :FailedDependency then return 'Failed Dependency' :u .
79- when StatusCodeEnum :UpgradeRequired then return 'Upgrade Required' :u .
80- when StatusCodeEnum :PreconditionRequired then return 'Precondition Required' :u .
81- when StatusCodeEnum :TooManyRequests then return 'Too Many Requests' :u .
82- when StatusCodeEnum :RequestHeaderFieldsTooLarge then return 'Request Header Fields Too Large' :u .
78+ when StatusCodeEnum :IAmATeapot then return 'I am a teapot' :u .
79+ when StatusCodeEnum :MisdirectedRequest then return 'Misdirected Request' :u .
80+ when StatusCodeEnum :UnprocessableEntity then return 'Unprocessable Entity' :u .
81+ when StatusCodeEnum :FailedDependency then return 'Failed Dependency' :u .
82+ when StatusCodeEnum :TooEarly then return 'Too Early' :u .
83+ when StatusCodeEnum :UpgradeRequired then return 'Upgrade Required' :u .
84+ when StatusCodeEnum :PreconditionRequired then return 'Precondition Required' :u .
85+ when StatusCodeEnum :TooManyRequests then return 'Too Many Requests' :u .
86+ when StatusCodeEnum :RequestHeaderFieldsTooLarge then return 'Request Header Fields Too Large' :u .
87+ when StatusCodeEnum :UnavailableForLegalReasons then return 'Unavailable For Legal Reasons' :u .
8388 /* 5xx */
8489 when StatusCodeEnum :InternalServerError then return 'Internal Server Error' :u .
8590 when StatusCodeEnum :NotImplemented then return 'Not Implemented' :u .
@@ -90,33 +95,33 @@ class OpenEdge.Net.HTTP.StatusCodeHelper:
9095 when StatusCodeEnum :VariantAlsoNegotiates then return 'Variant Also Negotiates' :u .
9196 when StatusCodeEnum :InsufficientStorage then return 'Insufficient Storage' :u .
9297 when StatusCodeEnum :LoopDetected then return 'Loop Detected' :u .
93- when StatusCodeEnum :NotExtended then return 'Not Extended' :u .
98+ when StatusCodeEnum :NotExtended then return 'Not Extended' :u . // OBSOLETE (RFC 2774 experimental). Maintained for backward compatibility only.
9499 when StatusCodeEnum :NetworkAuthenticationRequired then return 'Network AuthenticationRequired' :u .
95100 /* single word */
96101 otherwise return string (poStatusCode ).
97102 end case .
98103 end method .
99-
104+
100105 /* Finds the default status code enum for a status message, if possible.
101106 Returns StatusCodeEnum:Unknown if the text cannot be converted into an
102107 existing enum.
103-
108+
104109 @param character The status text
105110 @return StatusCodeEnum A status code enumeration based on the name */
106111 method public static StatusCodeEnum GetCode (input pcStatusMessage as character ):
107112 define variable oCode as StatusCodeEnum no-undo .
108-
109- Assert :NotNull (pcStatusMessage , ' Status message' ).
110-
113+
114+ Assert :NotNull (pcStatusMessage , ' Status message' ).
115+
111116 if pcStatusMessage eq ' ' :u then
112117 assign oCode = StatusCodeEnum :None .
113118 else
114119 assign oCode = StatusCodeEnum :GetEnum (replace (pcStatusMessage , ' ' :u , ' ' :u )) no-error .
115-
116- if not valid-object (oCode ) then
120+
121+ if not valid-object (oCode ) then
117122 assign oCode = StatusCodeEnum :Unknown .
118-
123+
119124 return oCode .
120125 end method .
121-
126+
122127end class .
0 commit comments