[
https://issues.jboss.org/browse/ISPN-3770?page=com.atlassian.jira.plugin....
]
Martin Gencur commented on ISPN-3770:
-------------------------------------
Jiri, I looked at the implementation and it works as follows:
When an object is stored via REST with Content-Type:
application/x-java-serializable-object , it does not matter what Content-Type you ask for
when retrieving the data with REST. It will always return the same Content-Type the data
was stored with.
Accepting JSON or XML should work only in compatibility mode when the data was stored in
library mode or via HotRod. Also, if you store plain byte array via library mode or
HotRod, you cannot specify Accept header when later retrieving the data via REST. The
content-type of the returned entry will be always APPLICATION_OCTET_STREAM. You'd have
to store POJO in order to be able to get back json/xml later via REST.
Incorrect Content-Type header when putting object via REST and get
with different Accept
----------------------------------------------------------------------------------------
Key: ISPN-3770
URL:
https://issues.jboss.org/browse/ISPN-3770
Project: Infinispan
Issue Type: Bug
Components: Server
Reporter: Jiří Holuša
Assignee: Mircea Markus
When putting serialized object via REST post and then getting it back with different
Accept header (for example application/json), the retrieved data has still the
"creation-time" Content-Type and data doesn't change in any way.
I would expect retrieving nice json structure for instace.
Code snippet:
{code}
public void testCustomObjectGetAcceptJSONAndXML() throws Exception{
String fullPathKeyA = fullPathKey(KEY_A);
TestSerializable object = new TestSerializable("CONTENT");
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oo = new ObjectOutputStream(bout);
oo.writeObject(object);
oo.flush();
oo.close();
byte[] byteData = bout.toByteArray();
post(fullPathKeyA, byteData, "application/x-java-serialized-object");
HttpResponse getJson = get(fullPathKeyA, null, HttpServletResponse.SC_OK, true,
"Accept", "application/json");
assertTrue(getJson.getHeaders("Content-type")[0].getValue().contains("application/json"));
//this assertion fails
HttpResponse getXml = get(fullPathKeyA, null, HttpServletResponse.SC_OK, true,
"Accept", "application/xml");
assertTrue(getXml.getHeaders("Content-type")[0].getValue().contains("application/xml"));
//this assertion fails
}
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira