OpenComputers icon indicating copy to clipboard operation
OpenComputers copied to clipboard

RFC 5789 (Section 2) Support: Support for "PATCH" HTTP Method

Open tycoonlover1359 opened this issue 5 years ago • 3 comments

As the title states, it would be very nice if support could be added for the PATCH HTTP Method as defined in section 2 of RFC 5789.

As it stands now, I have run into one website (quite popular) website that only supports the HTTP verbs as a way of handling requests; in other words, only the verb itself is used to tell the website how to process the data sent to it and inserting the X-HTTP-Method-Override header results in the website returning a 422 Unprocessable Entity error, thereby resulting in an error and/or simply malformed (or just nil) content when trying to act upon the response from the website

The website in question is Airtable, a fairly popular online NoSQL (at least in terms of the programming required to interface with it) database similar to that of RestDB.

Airtable requires the use of HTTP verbs in order to process requests sent to its APIs. Due to the mod believing that a PATCH request is an invalid HTTP method, non-destructively updating records within Airtable is impossible; a non-destructive update being an update that only updates the fields specified within the request body. Fully destructive updates are fine, as those make use of PUT requests, which are supported. As alluded to earlier, the X-HTTP-Method-Override header is not supported by Airtable and will result in 422 error.

Support for the PATCH HTTP method in RFC 5789 would be greatly appreciated, as I'm sure Airtable isn't the only website that does not allow for the use of the X-HTTP-Method-Override header.

Thanks.

tycoonlover1359 avatar Oct 05 '20 07:10 tycoonlover1359

OpenComputers uses HttpUrlConnection to make HTTP requests, which sadly doesn't support PATCH. It's fairly odd, but I guess PATCH is a relatively recent addition.

CC: Tweaked got around that by rewriting HTTP to use Netty's HTTP support (which has the additional advantage of not requiring a thread for each request). I suspect that's the easiest solution for OC, but I realise that's a fairly hefty piece of work.

SquidDev avatar Oct 05 '20 08:10 SquidDev

Hmmm, well alrighty then.

I do agree with you that it is fairly odd that HttpUrlConnection doesn't support PATCH, given that RFC 5789 was released in March of 2010 which is over 10 years ago and about 10 years after the initial release of RFC 2068.; RFC 2068 being the document that, at first glance, is what defines the methods we use most often, like GET, POST, PUT, etc.

I suppose that at some point in the future, perhaps I (or preferably someone more experienced with mod making, since I'm more of a web developer that also happens to play Minecraft) could make an "Internet Card V.2" or "Improved Internet Card" for OC as a substitute for OC's own internet card (at least until when it's decided that rewriting the Internet card, if it ever is).

(...or someone/some people could try and convince Oracle to add support for PATCH in HttpUrlConnection...but if it hasn't happened in 10 years, I have my doubts about it happening any time soon.)

tycoonlover1359 avatar Oct 05 '20 16:10 tycoonlover1359

I solidarity to that! I also want to use PATCH method for GithubAPI. It may be useful for solve: https://stackoverflow.com/questions/25163131/httpurlconnection-invalid-http-method-patch/46323891#46323891

hohserg1 avatar Nov 12 '20 09:11 hohserg1

I had to revert this PR as HttpClient is not shipped on the dedicated server.

asiekierka avatar May 30 '23 18:05 asiekierka