DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10277>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10277

Cannot set MIME type for ResourceReader

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CLOSED                      |REOPENED
         Resolution|INVALID                     |



------- Additional Comments From [EMAIL PROTECTED]  2002-06-27 14:22 -------
Look closely, it *is* ignored if reader.getMimeType() does not return null:
>From AbstractStreamPipeline.java:
      mimeType = this.reader.getMimeType();
      if ( mimeType != null ) {
          environment.setContentType(mimeType);
      } else if ( readerMimeType != null ) {
          environment.setContentType(this.readerMimeType);
      } else {
          environment.setContentType(this.sitemapReaderMimeType);
      }
CachingStreamPipeline has identical code (bad reuse).
In ResourceReader.java, getMimeType() is redefined as
    public String getMimeType () {
        Context ctx = ObjectModelHelper.getContext(this.objectModel);

        if (ctx != null) {
           return ctx.getMimeType(this.source);
        } else {
           return null;
        }
    }
This means, if there is a MIME type defined for the file in web.xml
for the webapp or for the whole server, this is used instead of the
MIME type declared in the map:reader.
The correct patch appears to be to move the code looking up the MIME
type from the context from ResourceReader to AbstractStreamPipeline:
and perhaps factor out the whole content type setting code into a
protected method for reuse in derived classes.
The logic would then be:
- Ask the Reader for a MIME type. A *.doc reader could peek into the file
  and return either text/plain or application/vnd.msword.
- MIME type declared on the reader instance
- MIME type declared for the reader component
- MIME type declared in WEB-INF/web.xml or by the server.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to