Hi Jerome, I've just tried again with Restlet 2.0M4 and have no major problems, all browsers now display files fine and HTTPFox reports the correct Content-Type header.
Thanks for fixing this annoying bug! On Mon, Aug 17, 2009 at 10:18 AM, Jerome Louvel<[email protected]> wrote: > Hi Fabian, > > Have you tried again with 2.0 M4? If you still have the issue, I suggest > creating an issue in the tracker for it. > > Best regards, > Jerome Louvel > -- > Restlet ~ Founder and Lead developer ~ http://www.restlet.org > Noelios Technologies ~ Co-founder ~ http://www.noelios.com > > > > > -----Message d'origine----- > De : Fabian Mandelbaum [mailto:[email protected]] > Envoyé : mercredi 5 août 2009 15:59 > À : [email protected] > Objet : Keep fighting content issues with restlet 2.0-snapshot (from July 9th) > > Hello there, here I am again with my content issues with restlet > 2.0-snapshot (from 2009-07-09): > > The Content-Type header of the response is always set to */* > (according to the HttpFox http traffic monitor), no matter which > MediaType I pass to the representation constructor of the returned > representation. > > example code for a ServerResource retrieving a file and 'streaming' it > back to the client: > > �...@get > �...@override > public Representation get() throws ResourceException { > long lstart = System.currentTimeMillis(); > Session session = null; > try { > session = RepoManager.getInstance().getSessionRO(); > StaticContentDAO dao = new StaticContentDAO(session); > Content content = dao.retrieve(ffname); > File tempFile = File.createTempFile("cco", null); // NOI18N > FileUtils.forceDeleteOnExit(tempFile); > FileOutputStream fos = FileUtils.openOutputStream(tempFile); > IOUtils.copy(new AutoCloseInputStream(content.getFstream()), fos); > MediaType mt = > getApplication().getMetadataService().getMediaType(FilenameUtils.getExtension(ffname)); > getLogger().info(String.format("%s has media type %s", ffname, > mt)); > FileRepresentation rep = new FileRepresentation(tempFile, mt); > DateTime dt = new DateTime(); > dt = dt.plusYears(2); // 2 yrs from now ("far future") > rep.setExpirationDate(dt.toDate()); > return rep; > } > catch (Exception e) { > // Error 500 > String msg = String.format("Backend (JCR/IO) problem > retrieveing /%s", ffname); > throw new ResourceException(Status.SERVER_ERROR_INTERNAL, msg, e); > } > finally { > if (session != null) > session.logout(); > long lstop = System.currentTimeMillis(); > getLogger().info(String.format("Request processed in > %2.3f sec.", > (lstop - lstart) / 1000.0)); > } > } > > > ffname is "login.html", which is a simple XHTML 1.0 Transitional page. > The logger output is correctly: login.html has media type text/html > However, the Content-Type header of the response is not text/html (as > it should), but */* > This happens also for other media types (correctly identified by the > MetaDataService), not just for html, */* is *always* set as > Content-Type > This little 'feature' is making most web browsers (IE and Safari) > asking me to download the page (which they don't even recognize it's > an html file, they take it to be binary) instead of displaying it. > Firefox works fine, and IIRC, Opera and Chrome too. > > Is this is known issue? Am I the only one testing my app in more than > one browser? Was this reported before and fixed in the current 2.0 > snapshot? > > Thanks in advance for your (as usual) prompt and accurate answers. > > -- > Fabián Mandelbaum > IS Engineer > > ------------------------------------------------------ > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2380455 > > ------------------------------------------------------ > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384327 > -- Fabián Mandelbaum IS Engineer ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384387

