<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>15771</bug_id>
          
          <creation_ts>2007-10-30 18:53:32 -0700</creation_ts>
          <short_desc>WebKit fails to recognize this file as text/plain and downloads it instead</short_desc>
          <delta_ts>2007-10-31 10:26:12 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>NeedsReduction</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Eric Seidel (no email)">eric</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>mitz</cc>
    
    <cc>mrowe</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>59889</commentid>
    <comment_count>0</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2007-10-30 18:53:32 -0700</bug_when>
    <thetext>WebKit fails to recognize this file as text/plain and downloads it instead

Just click on the attachment, if it opens instead of downloading, then this bug has been fixed.  I haven&apos;t tested with 2.0 it might be a regression, not sure.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59890</commentid>
    <comment_count>1</comment_count>
      <attachid>16955</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2007-10-30 18:54:05 -0700</bug_when>
    <thetext>Created attachment 16955
source file which should view instead of download</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59895</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-10-30 20:31:42 -0700</bug_when>
    <thetext>Attachment 16955 opened for me in the browser using a local debug build of WebKit r27223 with Safari 3 Public Beta v. 3.0.3 (522.12.1) on Mac OS X 10.4.10 (8R218).

Does it behave differently if opened from local disk?  Was this originally on another web site?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59896</commentid>
    <comment_count>3</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2007-10-30 20:37:58 -0700</bug_when>
    <thetext>I&apos;m using Leopard (upgrade install), with stock leopard Safari (I think... I can never remember if I have TOT running or not).  This was (and still is) hosted at http://www.eseidel.com/shifttest.c (my server), but it&apos;s sent there as text/plain as well.

Possibly related, when I try and upload a .cpp file and chose &quot;auto detect&quot; in Bugzilla, it bitches that my browser didn&apos;t send a mime type with the file.

That said, I would guess this is a decoder issue.  The decoder seeing the (abused) text/plain, not believing it, and then somehow determining that this should be a binary file instead of a text file.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59897</commentid>
    <comment_count>4</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-10-30 20:42:24 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; I&apos;m using Leopard (upgrade install), with stock leopard Safari (I think... I
&gt; can never remember if I have TOT running or not).  This was (and still is)
&gt; hosted at http://www.eseidel.com/shifttest.c (my server), but it&apos;s sent there
&gt; as text/plain as well.

That works fine as well in Tiger on the configuration in Comment #2.

Perhaps a Leopard-only issue?  Does CFNetwork do content sniffing now?

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59898</commentid>
    <comment_count>5</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-10-30 20:43:06 -0700</bug_when>
    <thetext>$ curl --head http://www.eseidel.com/shifttest.c
HTTP/1.1 200 OK
Date: Wed, 31 Oct 2007 03:42:46 GMT
Server: Apache/1.3.36 (Unix) mod_watch/3.17 mod_gzip/1.3.26.1a PHP/4.4.2 mod_ssl/2.8.27 OpenSSL/0.9.7a
Last-Modified: Wed, 31 Oct 2007 01:49:57 GMT
ETag: &quot;69200d-31f-4727df45&quot;
Accept-Ranges: bytes
Content-Length: 799
Content-Type: text/plain

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59917</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-10-31 02:34:21 -0700</bug_when>
    <thetext>This is very likely a CFNetwork issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59930</commentid>
    <comment_count>7</comment_count>
    <who name="">mitz</who>
    <bug_when>2007-10-31 07:51:53 -0700</bug_when>
    <thetext>I cannot reproduce with a nightly on Leopard. I believe this is &lt;rdar://problem/5313523&gt;, fixed in &lt;http://trac.webkit.org/projects/webkit/changeset/26758&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59943</commentid>
    <comment_count>8</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-10-31 10:23:42 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; I cannot reproduce with a nightly on Leopard. I believe this is
&gt; &lt;rdar://problem/5313523&gt;, fixed in
&gt; &lt;http://trac.webkit.org/projects/webkit/changeset/26758&gt;.

Won&apos;t you lose charset information (e.g., &quot;text/plain; charset=utf-8&quot;) if you only return &quot;text/plain&quot; in these cases, or does that not matter in this case?

Index: trunk/WebCore/platform/network/mac/ResourceResponseMac.mm
[...]
+#ifndef BUILDING_ON_TIGER
+        // FIXME: This is part of a workaround for &lt;rdar://problem/5321972&gt; REGRESSION: Plain text document from HTTP server detected
+        // as application/octet-stream
+        if (m_mimeType == &quot;application/octet-stream&quot;) {
+            static const String textPlainMIMEType(&quot;text/plain&quot;);
+            if (m_httpHeaderFields.get(&quot;Content-Type&quot;).startsWith(textPlainMIMEType))
+                m_mimeType = textPlainMIMEType;
+        }
+#endif

Index: trunk/WebKit/WebView/WebDataSource.mm
===================================================================
[...]
+#ifndef BUILDING_ON_TIGER
+- (NSString *)_MIMETypeOfResponse:(NSURLResponse *)response
+{
+    // FIXME: This is part of a workaround for &lt;rdar://problem/5321972&gt; REGRESSION: Plain text document from HTTP server detected
+    // as application/octet-stream
+    NSString *MIMEType = [response MIMEType];
+    if ([MIMEType isEqualToString:@&quot;application/octet-stream&quot;] &amp;&amp; [response isKindOfClass:[NSHTTPURLResponse class]] &amp;&amp; [[[(NSHTTPURLResponse *)response allHeaderFields] objectForKey:@&quot;Content-Type&quot;] hasPrefix:@&quot;text/plain&quot;])
+        return @&quot;text/plain&quot;;
+    return MIMEType;
+}
+#endif

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59944</commentid>
    <comment_count>9</comment_count>
    <who name="">mitz</who>
    <bug_when>2007-10-31 10:26:12 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; Won&apos;t you lose charset information (e.g., &quot;text/plain; charset=utf-8&quot;) if you
&gt; only return &quot;text/plain&quot; in these cases, or does that not matter in this case?

Returning that as the MIME type; leaving the Contetnt-type header intact.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>16955</attachid>
            <date>2007-10-30 18:54:05 -0700</date>
            <delta_ts>2007-10-30 18:54:05 -0700</delta_ts>
            <desc>source file which should view instead of download</desc>
            <filename>shifttest.c</filename>
            <type>text/plain</type>
            <size>799</size>
            <attacher name="Eric Seidel (no email)">eric</attacher>
            
              <data encoding="base64">I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyBBY2NvcmRpbmcgdG8gQzk5OgovLyAKLy8gaHR0cDovL3d3
dy5vcGVuLXN0ZC5vcmcvSlRDMS9TQzIyL1dHMTQvd3d3L2RvY3MvbjEyNTYucGRmCi8vIAovLyBU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