I have a reponsive bootstrap application and while trying to open the pdf from mobile getting error. I am able to open the pdf from iphone however from android chrome it says "media not supported exception"
I have my application type as "octet-stream"
Thanks for your help.
The application/octet-stream MIME should only be used when you don't know what the file contents is going to be, as it's for arbitrary binary data. The receiver has to attempt to work out what type it is, based on it's content and/or file extension.
You should be always use the appropriate MIME if it is known:
Content-Type: application/pdf
Content-Disposition: attachment; filename="document.PDF"
I'm trying to determine the mime type of a file. In Firefox, it shows text/cache-manifest. In Chrome, F-12 -> Network Tab it shows under type as document. When I view the response headers, it never shows Content-Type so maybe my server isn't sending it? Or am I interpreting document wrong?
In .htaccess, I have: AddType text/cache-manifest .manifest
EDIT: I have also tried the below code and it still shows type as document in Chrome:
manifest.php
<?php header("content-type: text/cache-manifest");?>
Network tab filters query based on request type, not mime type. As you request it as document (simple http get request in browser, not for example from image or styles tag), then it shows it as type=document.
See https://developers.google.com/web/tools/chrome-devtools/network/reference for more info.
Don't know why I'm facing this issue not able to download pdf files in chrome browser, it is showing below error in Nginx server.
resource interpreted as document but transferred with mime type application/octet-stream pdf
Though I have included mime type as application/pdf
If it's just a warning then simply ignore it! It's just Chrome.
If not, try to include MIME Type as application/octet-stream.
try to use those examples in your code.
PDFobject
this is a classic one:
if you can load localhost:8080/xyz123/PdfFile.pdf
then write like this:
<iframe src="./xyz123/PdfFile.pdf" title="title">
...
</iframe>
Similar issue came up for me only for .pdf files. I changed the Application Pool's idenity to Network Service and it fixed the issue.
I am not sure why it worked as the response header still had the same Content-Type, but it worked.
I'm working on an application that has a broken manifest file. It's broken in a bunch of ways.
One of the ways that it's broken is that it is being served as type text/plain.
Safari and Firefox ignore it because of this. None of Safari, Firefox, or Chrome show the manifest file being downloaded in firebug/inspector. Safari does show an error in its console about the incorrect mime type.
Only Chrome accepts the manifest file and creates an application cache. (This, of course, causes the application to break horribly, because the manifest's contents are wrong...)
I was under the impression that any manifest served with an incorrect mime type would be ignored.
Should manifests served as mime type text/plain be ignored? Is this a known bug in Chrome?
According to the specification a manifest must be served with mime-type text/cache-manifest.
If a browser interprets a manifest without that mime-type just because it was referenced in <html manifest="xxx"> it's not following the specification for 100%. But in my opinion: that's not a bug, it's a feature! :D
Aside that, why referencing a manifest without the correct mime-type anyway (instead of not referencing one at all)?
This, of course, causes the application to break horribly, because the manifest's contents are wrong...
Reading that I would assume that you just want to clean the appcache of Users already loaded the missconfigured manifest? If that's your intention so try it on the way described there: Removing HTML5 Appcache Manifest, Permanently
I just tried viewing my website http://www.logmytime.de/ in Opera (version 10.50) it gives me an "xml parsing failed error" and refuses to display the web page.
I can choose to "Reparse the document as HTML" and then the page works fine, but that's hardly a solution to my problem.
The weird thing is that the error still occurs after setting a HTML (instead of XTHML) doctype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
I checked the source output from the browser to make sure I did not make any mistake with the Doctype I even viewed the same web page in Firebug and it shows a Content-Type of text/html; .
So, why does Opera still try to parse my web page as XML?
Thanks,
Adrian
Edit: Just to clarify: I am not asking what the error on my web page is. I understand why this is not valid XHTML. However, I am also using the javascript micro templating engine, and it's templates are never valid XML, which is why I need the browser to parse my entire web site as HTML, not XHTML. In order to demonstrate this, I just inserted an example template into the web page.
<script type="text/html" id="StopWatchTemplate" >
<h1><#=currentlyRunning?"Aktueller":"Letzter"#> Stoppuhr-Zeiteintrag</h1>
<%-- Stoppuhr - Ende--%>
</script>
When opening the page in Opera, you can see that the template now produces XML parsing errors even though the doctype for the page is still HTML.
Edit 2:: Just to make this even clearer: I am not asking why my web page is not valid XHTML. I am asking why Opera tries to parse it as XHTML despite the HTML doctype.
Edit3:: Please do not post any more answers, I have found the cause of this and documented it below.
Your document is not a valid HTML document. So, the browser should reject it. Unfortunately, due to a historic accident, most browsers do not reject invalid documents, but rather try to fix them (usually with pretty crappy results), so that the authro never even notices that his document is broken.
Thankfully, with XHTML, the browser vendors decided to fix that, and actually reject invalid documents. In your case, you are delivering your document as XHTML with the application/xhtml+xml MIME type:# curl --head http://www.logmytime.de/
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 12529
Content-Type: application/xhtml+xml; charset=utf-8
^^^^^^^^^^^^^^^^^^^^^
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 2.0
X-AspNet-Version: 2.0.50727
Set-Cookie: Referrer=None; path=/
X-Powered-By: ASP.NET
Date: Tue, 04 May 2010 16:08:40 GMTSo, the browser rejects your document (as it should). When you switch over to HTML, then it tries to fix your broken HTML.
Now, you have changed your DOCTYPE to HTML 4.01, but you are still delivering it as XHTML. All you have achieved now is that there are two reasons for the browser to reject your document: it's still invalid because you haven't fixed the actual bug and the DOCTYPE and the MIME type don't match up.
Instead of mucking around with DOCTYPEs and MIME types in order to get the browser to parse your broken document, the correct way to solve this problem would be to simply fix the invalid markup and remove the extraneous class attribute on line 172. [BTW: who wrote that document? The indentation and formatting is awful.]
You have the "class" attribute specified two times.
From Well-formedness constraint: Unique Att Spec:
An attribute name MUST NOT appear more than once in the same start-tag or empty-element tag.
You got the correct answer (HTTP content-type header mandating XML parsing) and it seems it's fixed. I'll just add a minor hint on how you can figure out what's wrong from within Opera itself. Two possible ways:
1) Info panel
This is not visible by default, but if you open the panel bar on the left (press F4 to toggle if you don't see it), then click the small plus sign at the bottom, you can enable "Info" in the menu.
The info panel shows some assorted information about the page currently open, including encoding and MIME type.
2) Opera Dragonfly
Press Ctrl-Shift-I to open developer tools (or go through menus to Tools > Advanced > Opera Dragonfly)
Go to "Network" tab, then re-load site. You will see the request and can review the headers. Comparing this with corresponding information from Firebug would have shown you the difference in Content-type headers. (Here you will also see that Opera sends an "Accept" header that contains "application/xhtml+xml". This means "Hi server, if you happen to have this file in real XHTML format I would understand that just fine.". Perhaps your server-side framework saw that header and wrongly responded with the XHTML content-type even though the content was invalid?)
In case someone else has the same problem: As suggested by DeveloperArt it can be fixed with a simple ContentType="text/html" attribute in the page element.
Edit: The problem was in fact caused by a bug with the mobile.Browser file I am using in my web project. The workaround above works, but it is not really necessary in my case. See this answer for more details.
It seems like the server is serving a different mime types to different user-agents. Firefox is getting text/html but Opera (and curl according to Jörg W Mittag) is getting application/xhtml+xml. Do you have any content-negotiation code for your site?
Try from another PC to make sure that you're not hitting a cache issue.
The page code is cached in your browser, which is why you are continuing to see the error. You originally saw the error, because your code is likely not valid.
It is because you've kind of told it to...
<html xmlns="http://www.w3.org/1999/xhtml">
application/xhtml+xml
If the server sends the page as application/xhtml+xml, the browser parses it as XML as required by specification. When parsing as XML, the first XML well-formedness mistake will stop the parsing and the client (browser) usually displays an error message.
text/html
The parsers for text/html are more tolerant (due to the history of html development).
Changing the mime type
To change the content type sent by the server, you have to override the HTTP header value: Content-Type. This can be done through scripting language on the server side or sometimes in the configuration of the server such as Apache for example. I do not know how Microsoft-IIS/7.5 can specify on a URI base.
Content-Type: application/xhtml+xml; charset=utf-8
or
Content-Type: text/html; charset=utf-8
This mostly occurs with ASP.NET as it sets content type for opera as application/xhtml+xml. In order to over come this issue. You need to set content type to text/html. The best way to fix this issue is to add following code to .browser config file for opera in App_Browser file.
<capability name="preferredRenderingMime" value="text/html" />
<capability name="preferredRenderingType" value="html32" />
<capability name="SupportsXhtmlRendering" value="false" />