HTTPClient: Add PATCH method and missing HTTP status codes
This commit is contained in:
parent
aa5f5191f0
commit
a7abb459c9
3 changed files with 73 additions and 4 deletions
|
@ -93,7 +93,8 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector
|
|||
"DELETE",
|
||||
"OPTIONS",
|
||||
"TRACE",
|
||||
"CONNECT"
|
||||
"CONNECT",
|
||||
"PATCH"
|
||||
};
|
||||
|
||||
String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1\r\n";
|
||||
|
@ -153,7 +154,8 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str
|
|||
"DELETE",
|
||||
"OPTIONS",
|
||||
"TRACE",
|
||||
"CONNECT"
|
||||
"CONNECT",
|
||||
"PATCH"
|
||||
};
|
||||
|
||||
String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1\r\n";
|
||||
|
@ -683,6 +685,7 @@ void HTTPClient::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(METHOD_OPTIONS);
|
||||
BIND_ENUM_CONSTANT(METHOD_TRACE);
|
||||
BIND_ENUM_CONSTANT(METHOD_CONNECT);
|
||||
BIND_ENUM_CONSTANT(METHOD_PATCH);
|
||||
BIND_ENUM_CONSTANT(METHOD_MAX);
|
||||
|
||||
BIND_ENUM_CONSTANT(STATUS_DISCONNECTED);
|
||||
|
@ -709,6 +712,7 @@ void HTTPClient::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(RESPONSE_RESET_CONTENT);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_PARTIAL_CONTENT);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_MULTI_STATUS);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_ALREADY_REPORTED);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_IM_USED);
|
||||
|
||||
// 3xx redirection
|
||||
|
@ -718,7 +722,9 @@ void HTTPClient::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(RESPONSE_SEE_OTHER);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_NOT_MODIFIED);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_USE_PROXY);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_SWITCH_PROXY);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_TEMPORARY_REDIRECT);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_PERMANENT_REDIRECT);
|
||||
|
||||
// 4xx client error
|
||||
BIND_ENUM_CONSTANT(RESPONSE_BAD_REQUEST);
|
||||
|
@ -739,10 +745,16 @@ void HTTPClient::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(RESPONSE_UNSUPPORTED_MEDIA_TYPE);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_REQUESTED_RANGE_NOT_SATISFIABLE);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_EXPECTATION_FAILED);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_IM_A_TEAPOT);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_MISDIRECTED_REQUEST);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_UNPROCESSABLE_ENTITY);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_LOCKED);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_FAILED_DEPENDENCY);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_UPGRADE_REQUIRED);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_PRECONDITION_REQUIRED);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_TOO_MANY_REQUESTS);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_REQUEST_HEADER_FIELDS_TOO_LARGE);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_UNAVAILABLE_FOR_LEGAL_REASONS);
|
||||
|
||||
// 5xx server error
|
||||
BIND_ENUM_CONSTANT(RESPONSE_INTERNAL_SERVER_ERROR);
|
||||
|
@ -751,6 +763,9 @@ void HTTPClient::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(RESPONSE_SERVICE_UNAVAILABLE);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_GATEWAY_TIMEOUT);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_HTTP_VERSION_NOT_SUPPORTED);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_VARIANT_ALSO_NEGOTIATES);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_INSUFFICIENT_STORAGE);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_LOOP_DETECTED);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_NOT_EXTENDED);
|
||||
BIND_ENUM_CONSTANT(RESPONSE_NETWORK_AUTH_REQUIRED);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
RESPONSE_RESET_CONTENT = 205,
|
||||
RESPONSE_PARTIAL_CONTENT = 206,
|
||||
RESPONSE_MULTI_STATUS = 207,
|
||||
RESPONSE_ALREADY_REPORTED = 208,
|
||||
RESPONSE_IM_USED = 226,
|
||||
|
||||
// 3xx redirection
|
||||
|
@ -65,7 +66,9 @@ public:
|
|||
RESPONSE_SEE_OTHER = 303,
|
||||
RESPONSE_NOT_MODIFIED = 304,
|
||||
RESPONSE_USE_PROXY = 305,
|
||||
RESPONSE_SWITCH_PROXY = 306,
|
||||
RESPONSE_TEMPORARY_REDIRECT = 307,
|
||||
RESPONSE_PERMANENT_REDIRECT = 308,
|
||||
|
||||
// 4xx client error
|
||||
RESPONSE_BAD_REQUEST = 400,
|
||||
|
@ -86,10 +89,16 @@ public:
|
|||
RESPONSE_UNSUPPORTED_MEDIA_TYPE = 415,
|
||||
RESPONSE_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
|
||||
RESPONSE_EXPECTATION_FAILED = 417,
|
||||
RESPONSE_IM_A_TEAPOT = 418,
|
||||
RESPONSE_MISDIRECTED_REQUEST = 421,
|
||||
RESPONSE_UNPROCESSABLE_ENTITY = 422,
|
||||
RESPONSE_LOCKED = 423,
|
||||
RESPONSE_FAILED_DEPENDENCY = 424,
|
||||
RESPONSE_UPGRADE_REQUIRED = 426,
|
||||
RESPONSE_PRECONDITION_REQUIRED = 428,
|
||||
RESPONSE_TOO_MANY_REQUESTS = 429,
|
||||
RESPONSE_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
||||
RESPONSE_UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
||||
|
||||
// 5xx server error
|
||||
RESPONSE_INTERNAL_SERVER_ERROR = 500,
|
||||
|
@ -98,8 +107,11 @@ public:
|
|||
RESPONSE_SERVICE_UNAVAILABLE = 503,
|
||||
RESPONSE_GATEWAY_TIMEOUT = 504,
|
||||
RESPONSE_HTTP_VERSION_NOT_SUPPORTED = 505,
|
||||
RESPONSE_VARIANT_ALSO_NEGOTIATES = 506,
|
||||
RESPONSE_INSUFFICIENT_STORAGE = 507,
|
||||
RESPONSE_LOOP_DETECTED = 508,
|
||||
RESPONSE_NOT_EXTENDED = 510,
|
||||
RESPONSE_NETWORK_AUTH_REQUIRED = 511,
|
||||
|
||||
};
|
||||
|
||||
|
@ -113,10 +125,13 @@ public:
|
|||
METHOD_OPTIONS,
|
||||
METHOD_TRACE,
|
||||
METHOD_CONNECT,
|
||||
METHOD_PATCH,
|
||||
METHOD_MAX
|
||||
|
||||
};
|
||||
|
||||
enum Status {
|
||||
|
||||
STATUS_DISCONNECTED,
|
||||
STATUS_RESOLVING, //resolving hostname (if passed a hostname)
|
||||
STATUS_CANT_RESOLVE,
|
||||
|
|
|
@ -203,7 +203,7 @@
|
|||
<constant name="METHOD_GET" value="0" enum="Method">
|
||||
HTTP GET method. The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
|
||||
</constant>
|
||||
<constant name="METHOD_HEAD" value="1" enum="Method">#
|
||||
<constant name="METHOD_HEAD" value="1" enum="Method">
|
||||
HTTP HEAD method. The HEAD method asks for a response identical to that of a GET request, but without the response body. This is useful to request metadata like HTTP headers or to check if a resource exists.
|
||||
</constant>
|
||||
<constant name="METHOD_POST" value="2" enum="Method">
|
||||
|
@ -224,7 +224,10 @@
|
|||
<constant name="METHOD_CONNECT" value="7" enum="Method">
|
||||
HTTP CONNECT method. The CONNECT method establishes a tunnel to the server identified by the target resource. Rarely used.
|
||||
</constant>
|
||||
<constant name="METHOD_MAX" value="8" enum="Method">
|
||||
<constant name="METHOD_PATCH" value="8" enum="Method">
|
||||
HTTP PATCH method. The PATCH method is used to apply partial modifications to a resource.
|
||||
</constant>
|
||||
<constant name="METHOD_MAX" value="9" enum="Method">
|
||||
Marker for end of [code]METHOD_*[/code] enum. Not used.
|
||||
</constant>
|
||||
<constant name="STATUS_DISCONNECTED" value="0" enum="Status">
|
||||
|
@ -290,6 +293,9 @@
|
|||
<constant name="RESPONSE_MULTI_STATUS" value="207" enum="ResponseCode">
|
||||
HTTP status code [code]207 Multi-Status[/code] (WebDAV). A Multi-Status response conveys information about multiple resources in situations where multiple status codes might be appropriate.
|
||||
</constant>
|
||||
<constant name="RESPONSE_ALREADY_REPORTED" value="208" enum="ResponseCode">
|
||||
HTTP status code [code]208 Already Reported[/code] (WebDAV). Used inside a DAV: propstat response element to avoid enumerating the internal members of multiple bindings to the same collection repeatedly.
|
||||
</constant>
|
||||
<constant name="RESPONSE_IM_USED" value="226" enum="ResponseCode">
|
||||
HTTP status code [code]226 IM Used[/code] (WebDAV). The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
|
||||
</constant>
|
||||
|
@ -311,9 +317,15 @@
|
|||
<constant name="RESPONSE_USE_PROXY" value="305" enum="ResponseCode">
|
||||
HTTP status code [code]305 Use Proxy[/code]. Deprecated. Do not use.
|
||||
</constant>
|
||||
<constant name="RESPONSE_SWITCH_PROXY" value="306" enum="ResponseCode">
|
||||
HTTP status code [code]306 Switch Proxy[/code]. Deprecated. Do not use.
|
||||
</constant>
|
||||
<constant name="RESPONSE_TEMPORARY_REDIRECT" value="307" enum="ResponseCode">
|
||||
HTTP status code [code]307 Temporary Redirect[/code]. The target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI.
|
||||
</constant>
|
||||
<constant name="RESPONSE_PERMANENT_REDIRECT" value="308" enum="ResponseCode">
|
||||
HTTP status code [code]308 Permanent Redirect[/code]. The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.
|
||||
</constant>
|
||||
<constant name="RESPONSE_BAD_REQUEST" value="400" enum="ResponseCode">
|
||||
HTTP status code [code]400 Bad Request[/code]. The request was invalid. The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, invalid request contents, or deceptive request routing).
|
||||
</constant>
|
||||
|
@ -368,6 +380,12 @@
|
|||
<constant name="RESPONSE_EXPECTATION_FAILED" value="417" enum="ResponseCode">
|
||||
HTTP status code [code]417 Expectation Failed[/code]. The expectation given in the request's Expect header field could not be met by at least one of the inbound servers.
|
||||
</constant>
|
||||
<constant name="RESPONSE_IM_A_TEAPOT" value="418" enum="ResponseCode">
|
||||
HTTP status code [code]418 I'm A Teapot[/code]. Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout.
|
||||
</constant>
|
||||
<constant name="RESPONSE_MISDIRECTED_REQUEST" value="421" enum="ResponseCode">
|
||||
HTTP status code [code]421 Misdirected Request[/code]. The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.
|
||||
</constant>
|
||||
<constant name="RESPONSE_UNPROCESSABLE_ENTITY" value="422" enum="ResponseCode">
|
||||
HTTP status code [code]422 Unprocessable Entity[/code] (WebDAV). The server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), and the syntax of the request entity is correct (thus a 400 Bad Request status code is inappropriate) but was unable to process the contained instructions.
|
||||
</constant>
|
||||
|
@ -380,6 +398,18 @@
|
|||
<constant name="RESPONSE_UPGRADE_REQUIRED" value="426" enum="ResponseCode">
|
||||
HTTP status code [code]426 Upgrade Required[/code]. The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.
|
||||
</constant>
|
||||
<constant name="RESPONSE_PRECONDITION_REQUIRED" value="428" enum="ResponseCode">
|
||||
HTTP status code [code]428 Precondition Required[/code]. The origin server requires the request to be conditional.
|
||||
</constant>
|
||||
<constant name="RESPONSE_TOO_MANY_REQUESTS" value="429" enum="ResponseCode">
|
||||
HTTP status code [code]429 Too Many Requests[/code]. The user has sent too many requests in a given amount of time (see "rate limiting"). Back off and increase time between requests or try again later.
|
||||
</constant>
|
||||
<constant name="RESPONSE_REQUEST_HEADER_FIELDS_TOO_LARGE" value="431" enum="ResponseCode">
|
||||
HTTP status code [code]431 Rquest Header Fields Too Large[/code]. The server is unwilling to process the request because its header fields are too large. The request MAY be resubmitted after reducing the size of the request header fields.
|
||||
</constant>
|
||||
<constant name="RESPONSE_UNAVAILABLE_FOR_LEGAL_REASONS" value="451" enum="ResponseCode">
|
||||
HTTP status code [code]451 Response Unavailable For Legal Reasons[/code]. The server is denying access to the resource as a consequence of a legal demand.
|
||||
</constant>
|
||||
<constant name="RESPONSE_INTERNAL_SERVER_ERROR" value="500" enum="ResponseCode">
|
||||
HTTP status code [code]500 Internal Server Error[/code]. The server encountered an unexpected condition that prevented it from fulfilling the request.
|
||||
</constant>
|
||||
|
@ -398,11 +428,20 @@
|
|||
<constant name="RESPONSE_HTTP_VERSION_NOT_SUPPORTED" value="505" enum="ResponseCode">
|
||||
HTTP status code [code]505 HTTP Version Not Supported[/code]. The server does not support, or refuses to support, the major version of HTTP that was used in the request message.
|
||||
</constant>
|
||||
<constant name="RESPONSE_VARIANT_ALSO_NEGOTIATES" value="506" enum="ResponseCode">
|
||||
HTTP status code [code]506 Variant Also Negotiates[/code]. The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.
|
||||
</constant>
|
||||
<constant name="RESPONSE_INSUFFICIENT_STORAGE" value="507" enum="ResponseCode">
|
||||
HTTP status code [code]507 Insufficient Storage[/code]. The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.
|
||||
</constant>
|
||||
<constant name="RESPONSE_LOOP_DETECTED" value="508" enum="ResponseCode">
|
||||
HTTP status code [code]508 Loop Detected[/code]. The server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". This status indicates that the entire operation failed.
|
||||
</constant>
|
||||
<constant name="RESPONSE_NOT_EXTENDED" value="510" enum="ResponseCode">
|
||||
HTTP status code [code]510 Not Extended[/code]. The policy for accessing the resource has not been met in the request. The server should send back all the information necessary for the client to issue an extended request.
|
||||
</constant>
|
||||
<constant name="RESPONSE_NETWORK_AUTH_REQUIRED" value="511" enum="ResponseCode">
|
||||
HTTP status code [code]511 Network Authentication Required[/code]. The client needs to authenticate to gain network access.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
||||
|
|
Loading…
Reference in a new issue