http-header : content-type

http-header : content-type

This is a header which is helpful in indicating the media type of the resource. During the time of responses, this very header tells client about what the “content type” of the content to be returned actually is. In requests like, POST or PUT, the client informs or tells the server what type of data is actually sent.

This header is useful in specifying nature of data in an entity’s body, by providing the type and subtype identifiers, as well as by giving auxiliary information which might be needed for specific types. After mentioning about type as well as subtype names, the rest of the header is just a parameter, which is specified in form of attributes or value notation. For different types, the valid or meaningful sets of parameters differ. It is also seen that how the parameters are ordered is insignificant. Among the set of defined parameters is something called “charset” with the use of which the character set that is used in the body might be declared.

Generally, the term “Content-Type” is useful in declaring general type of data, where as its subtype focuses on a specific format for that specific data type. For example, a Content-Type holding “image/xyz” is quite good enough to inform user that the data is actually an image, even though the user has no specific knowledge whatsoever of the specific image format which is “xyz”. So, information such as this can be put to use, in order to decide whether or not the raw data is to be shown to a user from an unrecognized subtype that is; action such as this may stand reasonable for unrecognized subtypes of text, whereas not for unrecognized subtypes of image or audio. For this very reason, the registered subtypes of text, audio, video and image, shouldn’t by any means carry embedded information which is of different type.

Enablement in Apache:

The below mentioned syntax is added in “httpd.conf” file.

Header set Content-Type “text/plain” “expr=-z %{CONTENT_TYPE}”

The server is restarted so as make the configuration effective.

Enablement in Nginx:

The below mentioned syntax is added in to “nginx.conf” file under the server block.

add_header Content-Type “text/plain”;

The server then is restarted so as to show the results.

Enablement in Microsoft IIS:

Firstly, the IIS Manager is opened and then we move on to “HTTP Response Headers”. “Add” is clicked and then name and value of the header is typed in. Then “OK” is clicked and the server restarted so as to check the results.

 

Copyrights ©2008: Valency Networks Pvt Ltd.