As shown in Figure 9.19, IIS allows you to modify the contents of HTTP headers. Using ADSI, you can manipulate the HttpExpires , HttpCustomHeaders , HttpPics , and MimeMap properties to manipulate the information returned in the header of each HTML page sent to the browser.
These properties are useful for defining the expiration date of HTML content and defining any custom header information you want to send with all HTML transmissions. Additionally, you can define RSAC ratings for the content of individual resources to limit access to explicit content. Lastly, you can define a list of MIME types that should override the server-based MIME types.
If you maintain a site that is constantly providing fresh information on a particular page, you may want to configure content expiration for a directory or group of resources. By configuring content expiration, you can prevent the client browser or caching proxy server from presenting stale data to the client. This is especially important where ASP scripts are used to access databases ( assuming the developers have not already set Response. Expires =0) to guarantee that dynamic content is always generated from the query.
By default, IIS will not expire any HTTP content. To enable content expiration, you must set the HttpExpires property to a string in one of the formats found in Table 9.7.
String Definition | Description |
---|---|
Null | Content expiration is disabled. |
D, Hex ( time_in_seconds ) | Dynamic configuration. Defines the number of seconds until expiration. To specify content that never expires, use D,&HFFFFFFFF. To expire content immediately (recommended for ASP queries) use D, 0. |
S, UTCString | Defines the UTC date for expiration. Use the following string as a guide: S, Fri, 10 Sep 1999 00:15:56 GMT. |
To find the content expiration date for the bound resource, use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Debug.Print Resource.HttpExpires
To enable content expiration for a Web resource, use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim SiteIndex As Long Dim ContentExpiration As String ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value ContentExpiration = "D, 0" Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT") Resource.HttpExpires = ContentExpiration Resource.SetInfo
To customize the header information passed to the client with each HTTP request, you can define a custom HTTP header. By assigning a list of name and value pair strings to the HttpCustomHeaders property, you can establish custom HTTP headers for a particular resource.
These strings take the format Key: Value .
To find out the value of the current HTTP header configuration, you can use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") For Each HeaderEntry in Resource.HttpCustomHeaders Debug.Print HeaderEntry Next
In addition to industry standard HTTP header information, you can also establish custom HTTP header information. Use the following Visual Basic code as a guide to perform this task:
Dim Resource As IADs Dim ServerName As String Dim Index As Long Dim NewHeaderArray As Variant ServerName = "IIS_Server_Name" Index = Site_Index_Value NewHeaderArray = Array("HeaderName: HeaderValue") Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Resource.HttpCustomHeaders = NewHeaderArray Resource.SetInfo
Note
As shown in the code segment, HTTP headers should be formatted as Name: Value when assembling the array .
Unlike other forms of mass media, the World Wide Web is an extremely easy place to publish anything from photos of your family vacation to your recent flirtations with poetry. With such a wide variety of information available at our youth's fingertips, many parents and educational institutions have been wrestling with methods to reduce the impact of explicit material on future generations. One method commonly implemented by organizations that carry explicit content utilizes PICS ratings.
If your organization has elected to rate its generally available content, you can programmatically assign ratings to any given resource using ADSI, as shown in Figure 9.20.
The RSACi service rates content is listed in Table 9.8.
Criteria | Level | Description |
---|---|---|
Violence | No violence or sports- related violence | |
Violence | 1 | Injury to a human being |
Violence | 2 | Destruction of realistic objects |
Violence | 3 | Aggressive violence or death to humans |
Violence | 4 | Rape or wanton, gratuitous violence |
Sex | Romance or innocent kissing | |
Sex | 1 | Passionate kissing |
Sex | 2 | Clothed sexual touching |
Sex | 3 | Non-explicit sexual acts |
Sex | 4 | Explicit sexual acts or sex crimes |
Nudity | None | |
Nudity | 1 | Revealing attire |
Nudity | 2 | Partial nudity |
Nudity | 3 | Frontal nudity |
Nudity | 4 | Frontal nudity (qualifying as provocative display) |
Language | None | |
Language | 1 | Mild expletives |
Language | 2 | Moderate expletives or profanity |
Language | 3 | Strong language or hate speech |
Language | 4 | Crude, vulgar language, or extreme hate speech |
By assigning a specially formatted string to the HttpPics property for a bound resource, you can set the PICS rating to the appropriate RSACi rating.
The format for the string is as follows :
"PICS-Label: (PICS-1.0 "http://www.rsac.org/ratingsv01.html" l by "contact_e-mail@company.com" on "year.month.dayThour:minute-GMToffset" exp "year.month.dayThour:minute-GMToffset" r (v n s n n n l n ))
For example, consider the following data:
Creation Date | 2 Jan 2000 “ 01:00pm |
Rating User | webmaster@dot.com |
Location | Chicago |
Expiration Date | 2 Jun 2000 |
Violence | 1 |
Nudity | 1 |
Sex | 1 |
Language | 1 |
The resulting PICs label would be as follows:
"PICS-Label: (PICS-1.0 "http://www.rsac.org/ratingsv01.html" l by "webmaster@dot.com" on "2000.0.02T13:00-0600" exp "2000.0.02T12:00-0600" r (v 1 s 1 n 2 l 1))
To find the RSACi ratings for the bound resource, use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim Index As Long Dim Entry As Variant ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") For Each Entry In Resource.HttpPics Debug.Print Entry Next
With the background information used to form the string required to enable ratings for the resource, consider the following Visual Basic code to establish RSACi ratings for a given site:
Dim Resource As IADs Dim ServerName As String Dim Index As Long Dim PICSLabel as String ServerName = "IIS_Server_Name" Index = Site_Index_Value PICSLabel = "PICS_Format_String" Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Resource.HttpPics = PICSLabel Resource.SetInfo
Note
The PICS string requires you to use a double quote as part of the string. To establish strings containing double quotes, simply double the number of quotes. An example follows:
"PICS-Label: (PICS-1.0 ""http://www.rsac.org/ratingsv01.html"" l by ""webmaster@dot.com"" on ""2000.0.02T13:00-0500"" exp ""2000.0.02T12:00- 2500"" r (v 1 s 1 n 2 l 1))
Just as you can define MIME types at the server level, you can also override MIME types at the resource level. Using the same procedure you used to set global MIME types, you can define how you want MIME type information to be passed in the header.
To query existing MIME type definitions for a resource, use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://"&ServerName&"/W3SVC/"&Index&"/ROOT") Debug.Print "Registered File Types:" For Each MimeMapping in Resource.MimeMap Debug.Print "Extension: "&MimeMapping.Extension&" MIME Content Type: "& MimeMapping.MimeType Next
To create a new MIME type definitions for a resource, use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim Index As Long Dim MimeMapping As Variant Dim NewMimeMapping As Variant Dim MimeExtension As String Dim MimeType As String Dim i As Integer MimeExtension = " New_MIME_Extension " MimeType = " New_MIME_Type " ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://"&ServerName&"/W3SVC/"&Index&"/ROOT") NewMimeMapping = Resource.GetEx("MimeMap") i = UBound(NewMimeMapping) + 1 ReDim Preserve NewMimeMapping(i) Set NewMimeMapping(i) = CreateObject("MimeMap") NewMimeMapping(i).MimeType = MimeType NewMimeMapping(i).Extension = MimeExtension Resource.PutEx ADS_PROPERTY_UPDATE, "MimeMap", NewMimeMapping Resource.SetInfo
Top |