Questions tagged [content-type]

The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient or, in the case of the HEAD method, the media type that would have been sent had the request been a GET.

The Content-Type entity-header field indicates the media type (or MIME type) of the entity-body sent to the recipient or, in the case of the HEAD method, the media type that would have been sent had the request been a GET.

Content-Type   = "Content-Type" ":" media-type

An example of the field for HTML documents is:

Content-Type: text/html; charset=ISO-8859-4

For a PNG file, it would be:

Content-Type: image/png

Source: http://www.w3.org/

HTTP Specification : Section 14 : Header Field Definitions

Wikipedia articles:

  1. MIME
  2. Internet media type
2233 questions
45
votes
3 answers

Utility of HTTP header "Content-Type: application/force-download" for mobile?

I am currently working on a PHP script that allows you to download media contents (video, audio, pictures...) from your mobile device by accessing a link. (i.e. http://www.my-web-site.com/download.php?id=7ejs8ap) My script worked very vell when I…
niconoe
  • 1,100
  • 1
  • 11
  • 25
44
votes
2 answers

What is the HTTP "content-type" to use for a blob of bytes?

What is the HTTP "content-type" to use when returning a blob of bytes in response to a client's GET request? In this case, the information payload is an object serialized using Python's Pickle library.
Chris Dutrow
  • 42,732
  • 59
  • 174
  • 243
43
votes
16 answers

"name" web pdf for better default save filename in Acrobat?

My app generates PDFs for user consumption. The "Content-Disposition" http header is set as mentioned here. This is set to "inline; filename=foo.pdf", which should be enough for Acrobat to give "foo.pdf" as the filename when saving the…
James Baker
  • 5,748
  • 3
  • 22
  • 28
39
votes
1 answer

Get the response Content-Type header from XHR

I would like to see whether the header was text/html or text/xml. If it was text/html then there was an error and I would rather catch that before proceeding.
700 Software
  • 77,509
  • 74
  • 213
  • 324
39
votes
3 answers

Set Content-Type to application/json in jsp file

I am created some jsp file that returns as a response some json string. But I see that the Content-Type is set to txt automatically My jsp code looks like <%@ page import="java.util.Random" %> <%@ page language="java" %> <%@ page session="false"…
Julias
  • 5,372
  • 14
  • 53
  • 78
38
votes
2 answers

What is the HTML5 alternative to the obsolete meta http-equiv=content-language.

I'm finishing up an HTML5 site that has a mixture of English and Mandarin Chinese. My validator (HTML5 Validator add-on for FF) is giving me this error: error: Using the “meta” element to specify the document-wide default language is obsolete.…
Drew
  • 5,970
  • 10
  • 42
  • 67
38
votes
4 answers

Unable to delete SharePoint 2010 ContentType "Contenty type in use."

I have tried all the recommendations on the web, to no avail. I wrote a console application per these instructions: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontenttypecollection.delete.aspx The "Usages.Count" is = 0. Yet, when…
Shayne
  • 1,033
  • 3
  • 16
  • 29
38
votes
8 answers

How to force parse request body as plain text instead of json in Express?

I am using nodejs + Express (v3) like this: app.use(express.bodyParser()); app.route('/some/route', function(req, res) { var text = req.body; // I expect text to be a string but it is a JSON }); I checked the request headers and the content-type…
pathikrit
  • 29,060
  • 33
  • 127
  • 206
36
votes
4 answers

Display image from http response with image content type

Let's say I have url and don't know what it will return. I perform ajax call to that url with javascript and get the content. So I test it's content-type and decide how to show response in my webpage. In case it is json or html or any other text, I…
ArVan
  • 3,925
  • 7
  • 34
  • 56
35
votes
7 answers

Http Post with request content type form not working in Spring MVC 3

code snippet: @RequestMapping(method = RequestMethod.POST)//, headers = "content-type=application/x-www-form-urlencoded") public ModelAndView create(@RequestBody UserAccountBean account) { try{ accounts.put(account.assignId(),…
Bobo
  • 7,707
  • 17
  • 56
  • 85
35
votes
3 answers

Content type for HTML fragments

When a server sends an HTTP response with an HTML document in the body, it would usually use the text/html content type. Should the content type be different if the reponse is a fragment of HTML? For example, if the request is AJAX from a client…
user213154
33
votes
10 answers

In C#, how can I know the file type from a byte[]?

I have a byte array filled from a file uploaded. But, in another part of the code, I need to know this file type uploaded from the byte[] so I can render the correct content-type to browser! Thanks!!
André Miranda
  • 5,980
  • 20
  • 67
  • 94
32
votes
8 answers

header("Content-type: text/css"); is working in Firefox and Chrome, but in Internet Explorer 9 it shows up as 'text/html'

header("Content-type: text/css"); works in Firefox, Chrome and other, but not in Internet Explorer 9. I am not sure what's up. In Chrome and Firework it shows the style sheet if I open it in its own tab and it's being applied to the page. In Chrome…
Keverw
  • 3,398
  • 7
  • 28
  • 51
32
votes
1 answer

Setting request header content-type to json in Spring Framework resttemplate

I'm learning Spring Framework to create a client of a REST web service that uses basic authentication and exchanges JSON. After much searching on the web, I wrote some code that worked (below), but now I'm getting an "Unsupported Media Type" error…
user2752012
  • 333
  • 1
  • 3
  • 7
31
votes
7 answers

How to get the content/type of a file at runtime

I am trying to determine dynamically the content/type of a input file. If I would be in a windows application I could write code like this (from this blog) private string GetContentType(string fileName) { string contentType =…
Lorenzo
  • 28,103
  • 43
  • 117
  • 208