Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.58k stars 591 forks source link

GH-439 Make `HttpMethod#all` static #440

Closed dzikoysk closed 2 years ago

dzikoysk commented 2 years ago
CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

dzikoysk commented 2 years ago

Oh, that's quite funny, because it looks like HttpMethod stores everything that have been requested:

    @Test
    void weirdVerbs() {
        Unirest.request("CHEESE", MockServer.CHEESE)
                .asObject(RequestCapture.class)
                .getBody()
                .assertMethod(HttpMethod.valueOf("CHEESE"))
                .assertBody("");
    }

Results later in:

Error:    
HttpMethodTest.shouldReturnAllMethods:51 
expected: <[PATCH, GET, OPTIONS, DELETE, POST, PUT, TRACE, HEAD]>
  but was: <[PATCH, CHEESE, GET, OPTIONS, DELETE, POST, PUT, TRACE, HEAD]>
dzikoysk commented 2 years ago

It looks like custom methods are considered as a feature, so what do you think about extending HttpMethod with a property canonic/standard, so we can differ those methods? Or we can just remove this test if the registry it meant to keep non-standard values for the whole jvm instance.

ryber commented 2 years ago

I'd just change the test to:

assertEquals(HttpMethod.GET.all(), HttpMethod.all());
ryber commented 2 years ago

You could also check that it contains the default (but might have more which is fine).

but yes, there re some systems with custom methods. mostly old