HTTP Request Header Application Analysis

Source: Internet
Author: User

Both ASP and PHP can customize header parameters, which are rarely used, but they are still very useful. Here we will summarize them.

UsageArticleTake ASP as an example:

ASP:

<%
Response. contenttype = "for details about contenttype settings, see"
Response. addheader "name", "value"
%>

PHP:

<%
Header ("Content-Type: contenttype setting can be found below ");
Header ("Name: Value ");
%>

Application:

1. Force download. Some file formats are opened by default in the browser, such as DOC files and Excel files. If you have installed office, it will be opened directly in the browser. More than a single file, PDF file. Sometimes, we hope it can be saved directly, especially for some download sections. At this time, you only need to add a header parameter:

<% Response. addheader "content-disposition", "attachment" %>

The download window is automatically opened.

2. Hide the file name. Sometimes, we do not want to tell others the file name, or even we do not have a file name, because many times the content is dynamically generated and there is no good file name, which is confusing to users, they have to change their names. At this time, we can add another value.

<% Response. addheader "content-disposition", "attachment; filename = file name you need to get" %>

PS: when calling the preceding statement, add the previous statement to set the document category.

Content-Type is in the form of "primary type/subtype. Main types include text, image, audio, video,
Application, multipart,
Message, indicating text, images, audio, video, application, segmentation, messages, etc. Each primary type may have multiple child types, for example, the text type contains plain,
HTML, XML,
CSS. The primary and subtypes starting with X-also indicate custom types. They are not officially registered with iana, but most of them have been agreed to be vulgar. For example, application/X-
Zip-compressed is a zip file. In Windows, the Registry's "hkey_classes_root \ mime \ database \
Content type lists most known content-types except multipart.

There are many supplementary provisions in the RFC regarding the form of parameters. Some may include several parameters.

Primary Type Parameter Name Description

The character set can also be seen in "hkey_classes_root \ mime \ database \ charset" in the Windows registry.

For example:

Excel: Application/vnd. ms_excel
Word: Application/MSWord
Image: image/GIF
HTML: text/html

I found it messy after writing it ...... I don't know whether I understand it or not. I just want to leave a message for me ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.