cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CXF-3667) Content negotiation & ResponseBuilder without entity - wrong Content-Type
Date Tue, 26 Jul 2011 20:42:09 GMT

     [ https://issues.apache.org/jira/browse/CXF-3667?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sergey Beryozkin resolved CXF-3667.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.5
                   2.4.2
         Assignee: Sergey Beryozkin

> Content negotiation & ResponseBuilder without entity - wrong Content-Type
> -------------------------------------------------------------------------
>
>                 Key: CXF-3667
>                 URL: https://issues.apache.org/jira/browse/CXF-3667
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.4.1
>            Reporter: Ɓukasz Strzelecki
>            Assignee: Sergey Beryozkin
>             Fix For: 2.4.2, 2.5
>
>
> With creation of response without content, based on javax.ws.rs.core.Response.ResponseBuilder.
I get wrong Content-Type. 
> Sample of REST resource (This is not valid rest service, but I want only show strange
behaviour)
> {code}
> package com.sozix.rest.service;
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.MediaType;
> import javax.ws.rs.core.Response;
> @Path("/hello")
> public class HelloResource {
> 	// 1
> 	@GET
> 	// 2
> 	@Produces(MediaType.APPLICATION_JSON)
> 	public Response greeting() {
> 		// 3
> 		return Response.noContent().build();
> 	}
> }
> {code}
> At 1) No matter which kind of request (GET, POST, PUT, DELETE) i will invoke. Issiue
is the same.
> At 2) I set that method produces ONLY Content-type: application/json
> At 3) Constructing response without content, using javax.ws.rs.core.Response.ResponseBuilder
> Invoking servcie
> $ curl *--header "Accept: application/json"* http://localhost:8080/hello -v
> I'm setting header that as client accept only JSON content type.
> {code}
> $ curl --header "Accept: application/json" http://localhost:8080/hello -v
> * About to connect() to localhost port 8080 (#0)
> *   Trying 127.0.0.1... connected
> * Connected to localhost (127.0.0.1) port 8080 (#0)
> > GET /hello HTTP/1.1
> > User-Agent: curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 OpenSSL/0.9.8q zlib/1.
> 2.5 libidn/1.18 libssh2/1.2.5
> > Host: localhost:8080
> > Accept: application/json
> >
> < HTTP/1.1 204 No Content
> < Content-Type: text/xml
> < Date: Mon, 18 Jul 2011 21:19:19 GMT
> < Server: Jetty(7.4.2.v20110526)
> <
> * Connection #0 to host localhost left intact
> * Closing connection #0
> {code}
> But as you can see at response i'm getting Content-Type: *text/xml*. Which is not i'm
expecting.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message