Adds a Content Type header to a request. Use this method to create a default header or one of the common defaults. For more complex header use the wwHTTPHeader object instead.
What's a content type?
Web requests require an HTTP header in order to let the browser know how to display the dynamically generated page. The header looks something like this:HTTP/1.0 200 OK Content-type: text/html <HTML> ...HTML content here. </HTML>
In the above example the Content Type line plus a blank line is the actual text that makes up the Content type header.
This method adds this ContentType header to a request. This method is also called internally by various other methods that manipulate the HTTP header. HTMLHeader() and any full page generation methods such as ExpandTemplate(), ExpandScript(), ErrorMsg() and StandardPage() pass forward their lvHeader parameter to this method.
o.ContenttypeHeader([loHTTPHeader | lcContentType], llNoOutput)
Parameters
lcContentType
For backward compatibility you can also call this method with a text parameterCGI requests require a Content Type header which usually looks like this in the generated document:
Common types are:
"text/html" - Default
"text/xml" - XML
"text/plain" - Text data
"Force Reload" - Force browser to always reload page
"Cache" - Maximum Cache Settings for this request
"none" - No header is sent - your code has to set it up
oHTTPHeader
A preconfigured wwHTTPHeader object that was previously set up and configured.
llNoOutput
Optional - Output to string and not to HTTP stream when set to .t..
Example
**** Simple Content Type Assignment on XML data lcXML = oXML.CursorToXML() Response.ContentTypeHeader("text/xml") Response.Write(lcXML) RETURN **** HTTP Header object **** lcId=Request.GetCookie("WWUSERID") *** Create Standard Header - here to add an HTTP Cookie loHeader=CREATEOBJECT("wwHTTPHeader") loHeader.DefaultHeader() *** If not Found IF EMPTY(lcId) *** Create the cookie lcId=SYS(3) loHeader.AddCookie("WWUSERID",lcId,"/wconnect") ENDIF *** Set the Content Type Header Response.ContentTypeHeader(loHeader) *** Alternately you can also pass the header to another method * Response.HTMLHeader("Cookie Test","Cookie Test Page",,loHeader) *** Followed by regular HTML text (any wwResponse methods valid) Response.Write("<HTML><BODY>") Response.Write("Cookie Value (wwUserId): <b>" +lcId +"</b><p> ") Response.Write("</BODY></HTML>") RETURN
See also:
Class wwResponse | Class wwHTTPHeader | wwResponse::expandtemplate | wwResponse::expandscript | wwResponse::htmlheader© West Wind Technologies, 1996-2024 • Updated: 11/26/15
Comment or report problem with topic