From a7abb459c91156e0326018bbd7274c9a425e1087 Mon Sep 17 00:00:00 2001 From: mhilbrunner Date: Sun, 10 Dec 2017 23:18:44 +0100 Subject: [PATCH] HTTPClient: Add PATCH method and missing HTTP status codes --- core/io/http_client.cpp | 19 +++++++++++++++-- core/io/http_client.h | 15 +++++++++++++ doc/classes/HTTPClient.xml | 43 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 5097898314e..9d89baafb16 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -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 HTTP GET method. The GET method requests a representation of the specified resource. Requests using GET should only retrieve data. - # + 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. @@ -224,7 +224,10 @@ HTTP CONNECT method. The CONNECT method establishes a tunnel to the server identified by the target resource. Rarely used. - + + HTTP PATCH method. The PATCH method is used to apply partial modifications to a resource. + + Marker for end of [code]METHOD_*[/code] enum. Not used. @@ -290,6 +293,9 @@ 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. + + 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. + 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. @@ -311,9 +317,15 @@ HTTP status code [code]305 Use Proxy[/code]. Deprecated. Do not use. + + HTTP status code [code]306 Switch Proxy[/code]. Deprecated. Do not use. + 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. + + 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. + 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). @@ -368,6 +380,12 @@ 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. + + 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. + + + 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. + 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. @@ -380,6 +398,18 @@ 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. + + HTTP status code [code]428 Precondition Required[/code]. The origin server requires the request to be conditional. + + + 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. + + + 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. + + + 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. + HTTP status code [code]500 Internal Server Error[/code]. The server encountered an unexpected condition that prevented it from fulfilling the request. @@ -398,11 +428,20 @@ 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. + + 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. + 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. + + 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. + 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. + + HTTP status code [code]511 Network Authentication Required[/code]. The client needs to authenticate to gain network access. +