rest icon indicating copy to clipboard operation
rest copied to clipboard

Client Should Support HTTP Patch Method

Open hantsy opened this issue 1 year ago • 8 comments

Currently SyncInvoker does not include a patch method, should add patch and align to JSON PATCH/Merge Patch support in the server side.

hantsy avatar Jul 13 '24 07:07 hantsy

This can be done by invoking SyncInvoker.method("PATCH").

jamezp avatar Jul 15 '24 15:07 jamezp

Currently SyncInvoker does not include a patch method, should add patch and align to JSON PATCH/Merge Patch support in the server side.

@hantsy Could you please elaborate on chosing the term "SHOULD"? IMHO this is rather nice to have.

mkarg avatar Jul 15 '24 15:07 mkarg

For a Chinese, in my mind, SHOULD may be just an emphasis of nice to have :)

hantsy avatar Jul 16 '24 03:07 hantsy

@jamezp Already used it, https://github.com/hantsy/jakartaee11-sandbox/blob/master/rest/src/test/java/com/example/it/ArticleResourceTest.java#L179

But here it requires a property for the client, .property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true).

Of course, I hope a simple patch() to replace this.

hantsy avatar Jul 16 '24 03:07 hantsy

@hantsy I'm not sure what HttpUrlConnectorProvider.SET_METHOD_WORKAROUND does, but it's implementation specific so it might still be needed.

I've got no strong opinion on adding or not adding really, just showing there is a fairly simply workaround for it.

jamezp avatar Jul 16 '24 15:07 jamezp

For a Chinese, in my mind, SHOULD may be just an emphasis of nice to have :)

This term has special meaning in JAX-RS and other specifications: https://github.com/jakartaee/rest/blob/main/jaxrs-spec/src/main/asciidoc/chapters/introduction/_conventions.adoc. It is not country-dependent.

mkarg avatar Jul 16 '24 17:07 mkarg

.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true)

This is Jersey specific, using reflection to allow JDK HttpUrlConnection for having an HTTP method not supported by the JDK. However, it does not work on JDK 16+ without --add-open on JDK packages, which may be forbidden in customer production environments.

The requirement is understandable, but difficult to reach. The JDK HttpUrlConnection does not support it, and the java.net.http implementation of HttpClient is very limiting in what it allows, many use-cases are not possible to implement.

The requirement, if mandatory, could lead to a requirement for each Jakarta-REST implementation to actually implement an HTTP Client that supports all the use-cases (or find a third-party client that is capable of doing so and be inherently dependent on it).

jansupol avatar Jul 23 '24 08:07 jansupol

This is Jersey specific, using reflection to allow JDK HttpUrlConnection for having an HTTP method not supported by the JDK.

I would like use a modern Http connector enigne.

hantsy avatar Aug 31 '24 02:08 hantsy