Spring implicit HTTP OPTIONS method returning wrong “Allow” response headers












0















I'm using Spring 4.3.3 which has built-in support for HTTP HEAD and OPTIONS. I've defined my REST API to support only GET method but the implicit OPTIONS method returns other HTTP methods: POST, GET, OPTIONS, HEAD.



When I invoke the API using the POST method, I get the HTTP 405 error as expected. Why is the Spring implicit OPTIONS method returning the wrong "Allow" response headers?



My REST service:



@Service
@Produces("application/json")
@Consumes("application/json")
@Path("/test")
public class TestJaxrs {
@GET
@Path("/testJaxrs")
public String test() {
return "test ok";
}
}


Actual response header:



Allow: POST, GET, OPTIONS, HEAD


I'm expecting the response header to be:



Allow: GET









share|improve this question























  • You try to call "/test/testJaxrs" by using POST ?

    – TinyOS
    Nov 21 '18 at 12:38











  • Why you are using JAX-RS API while you have Spring RestController & GetMapping annotations etc?

    – Gaurav Srivastav
    Nov 21 '18 at 12:40











  • @TinyOS, yes, the POST method on the /test/testJaxrs URL returns HTTP 405

    – happymeal
    Nov 21 '18 at 14:16











  • @GauravSrivastav for the TestJaxrs class, I'm only using JAX-RS annotations and no Spring annotations apart from Service. The Service annotation is required by CXF JAX-RS for component scan.

    – happymeal
    Nov 21 '18 at 14:20
















0















I'm using Spring 4.3.3 which has built-in support for HTTP HEAD and OPTIONS. I've defined my REST API to support only GET method but the implicit OPTIONS method returns other HTTP methods: POST, GET, OPTIONS, HEAD.



When I invoke the API using the POST method, I get the HTTP 405 error as expected. Why is the Spring implicit OPTIONS method returning the wrong "Allow" response headers?



My REST service:



@Service
@Produces("application/json")
@Consumes("application/json")
@Path("/test")
public class TestJaxrs {
@GET
@Path("/testJaxrs")
public String test() {
return "test ok";
}
}


Actual response header:



Allow: POST, GET, OPTIONS, HEAD


I'm expecting the response header to be:



Allow: GET









share|improve this question























  • You try to call "/test/testJaxrs" by using POST ?

    – TinyOS
    Nov 21 '18 at 12:38











  • Why you are using JAX-RS API while you have Spring RestController & GetMapping annotations etc?

    – Gaurav Srivastav
    Nov 21 '18 at 12:40











  • @TinyOS, yes, the POST method on the /test/testJaxrs URL returns HTTP 405

    – happymeal
    Nov 21 '18 at 14:16











  • @GauravSrivastav for the TestJaxrs class, I'm only using JAX-RS annotations and no Spring annotations apart from Service. The Service annotation is required by CXF JAX-RS for component scan.

    – happymeal
    Nov 21 '18 at 14:20














0












0








0








I'm using Spring 4.3.3 which has built-in support for HTTP HEAD and OPTIONS. I've defined my REST API to support only GET method but the implicit OPTIONS method returns other HTTP methods: POST, GET, OPTIONS, HEAD.



When I invoke the API using the POST method, I get the HTTP 405 error as expected. Why is the Spring implicit OPTIONS method returning the wrong "Allow" response headers?



My REST service:



@Service
@Produces("application/json")
@Consumes("application/json")
@Path("/test")
public class TestJaxrs {
@GET
@Path("/testJaxrs")
public String test() {
return "test ok";
}
}


Actual response header:



Allow: POST, GET, OPTIONS, HEAD


I'm expecting the response header to be:



Allow: GET









share|improve this question














I'm using Spring 4.3.3 which has built-in support for HTTP HEAD and OPTIONS. I've defined my REST API to support only GET method but the implicit OPTIONS method returns other HTTP methods: POST, GET, OPTIONS, HEAD.



When I invoke the API using the POST method, I get the HTTP 405 error as expected. Why is the Spring implicit OPTIONS method returning the wrong "Allow" response headers?



My REST service:



@Service
@Produces("application/json")
@Consumes("application/json")
@Path("/test")
public class TestJaxrs {
@GET
@Path("/testJaxrs")
public String test() {
return "test ok";
}
}


Actual response header:



Allow: POST, GET, OPTIONS, HEAD


I'm expecting the response header to be:



Allow: GET






java spring spring-boot jax-rs cxf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 11:49









happymealhappymeal

1,1581121




1,1581121













  • You try to call "/test/testJaxrs" by using POST ?

    – TinyOS
    Nov 21 '18 at 12:38











  • Why you are using JAX-RS API while you have Spring RestController & GetMapping annotations etc?

    – Gaurav Srivastav
    Nov 21 '18 at 12:40











  • @TinyOS, yes, the POST method on the /test/testJaxrs URL returns HTTP 405

    – happymeal
    Nov 21 '18 at 14:16











  • @GauravSrivastav for the TestJaxrs class, I'm only using JAX-RS annotations and no Spring annotations apart from Service. The Service annotation is required by CXF JAX-RS for component scan.

    – happymeal
    Nov 21 '18 at 14:20



















  • You try to call "/test/testJaxrs" by using POST ?

    – TinyOS
    Nov 21 '18 at 12:38











  • Why you are using JAX-RS API while you have Spring RestController & GetMapping annotations etc?

    – Gaurav Srivastav
    Nov 21 '18 at 12:40











  • @TinyOS, yes, the POST method on the /test/testJaxrs URL returns HTTP 405

    – happymeal
    Nov 21 '18 at 14:16











  • @GauravSrivastav for the TestJaxrs class, I'm only using JAX-RS annotations and no Spring annotations apart from Service. The Service annotation is required by CXF JAX-RS for component scan.

    – happymeal
    Nov 21 '18 at 14:20

















You try to call "/test/testJaxrs" by using POST ?

– TinyOS
Nov 21 '18 at 12:38





You try to call "/test/testJaxrs" by using POST ?

– TinyOS
Nov 21 '18 at 12:38













Why you are using JAX-RS API while you have Spring RestController & GetMapping annotations etc?

– Gaurav Srivastav
Nov 21 '18 at 12:40





Why you are using JAX-RS API while you have Spring RestController & GetMapping annotations etc?

– Gaurav Srivastav
Nov 21 '18 at 12:40













@TinyOS, yes, the POST method on the /test/testJaxrs URL returns HTTP 405

– happymeal
Nov 21 '18 at 14:16





@TinyOS, yes, the POST method on the /test/testJaxrs URL returns HTTP 405

– happymeal
Nov 21 '18 at 14:16













@GauravSrivastav for the TestJaxrs class, I'm only using JAX-RS annotations and no Spring annotations apart from Service. The Service annotation is required by CXF JAX-RS for component scan.

– happymeal
Nov 21 '18 at 14:20





@GauravSrivastav for the TestJaxrs class, I'm only using JAX-RS annotations and no Spring annotations apart from Service. The Service annotation is required by CXF JAX-RS for component scan.

– happymeal
Nov 21 '18 at 14:20












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411421%2fspring-implicit-http-options-method-returning-wrong-allow-response-headers%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411421%2fspring-implicit-http-options-method-returning-wrong-allow-response-headers%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]