cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barry Fitzgerald" <barfitzger...@gmail.com>
Subject Jax-RS Accept headers
Date Fri, 01 Feb 2008 15:54:19 GMT
Hi,

I'm pretty new to this so bear with me.

I think there is a bug handling Jax-RS accept headers in the latest trunk
code. When a request is passed in with a comma separated list of accept
headers these are not parsed correctly.

eg. A request with accept headers of *
"text/xml,application/xml,application/xhtml+xml"* will not match a produce
Mime of *"text/xml"*

A similar problem was fixed by this commit r615303:

http://svn.apache.org/viewvc?rev=615303&view=rev

However a similar fix need to added to
org.apache.cxf.jaxrs.JAXRSUtils.matchMimeTypes()

Line 261-268 needs to replaced with:

+        List<String> types = new ArrayList<String>();
         if (acceptContentType != null) {
+            while (acceptContentType.length() > 0) {
+                String tp = acceptContentType;
+                if (acceptContentType.contains(",")) {
+                    tp = acceptContentType.substring(0,
acceptContentType.indexOf(','));
+                    acceptContentType = acceptContentType
+                        .substring(acceptContentType.indexOf(',') + 1).trim();
+                } else {
+                    acceptContentType = "";
+                }
+                try {
+                    MimeType mt = new MimeType(tp);
+                    types.add(mt.getBaseType());
+                } catch (MimeTypeParseException e) {
+                    // ignore
+                }

And the resulting array passed into intersectMimeTypes()

Sorry I didn't do a patch for this but I need to persuade my employer it's
worth me spending time on this.

Regards,

Barry

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message