tfHttpdUserSetContentTypeFunc

Jump to: navigation, search

Table of Contents >> Application Reference >> Web Server


#include <trsocket.h>


int tfHttpdUserSetContentTypeFunc (
ttHttpdUserSrvHandle userSrvHandle,
ttHttpdUserContentTypeCBPtr funcPtr,
int length,
int flags
);


Function Description

Register a function for the web server to use to get the value of the Content-Type HTTP header field for the current page. The default behavior of the web server is to set the appropriate content type for static pages with common file extensions: jpg, gif, txt, htm, html, shtm, shtml, xml, and sxml. All other file extensions are given a content type of application/octet-stream and all CGI pages are given a content type of text/html. This function gives the user the ability to set custom content types for CGI pages or static pages with file extensions the server does not recognize. The server may also be configured to ignore the content types it knows by default and call the user’s function for all pages. When used for CGI, the user’s function is executed after the first call the user makes to either tfHttpdUserSendBuffer() or tfHttpdUserSendFile(). This function may be called multiple times to change its operational parameters. Calling it with a flags field of 0 will cause the web server to revert to the standard method of setting content type.


Parameters

  • userSrvHandle
    Handler returned from tfHttpdUserStart()
  • funcPtr
    User provided function that will set the value of the Content-Type HTTP header field for the current page
  • length
    The length of the buffer given to the user’s function to store the content type in, including the terminating null character
  • flags
    This parameter controls when the user’s function will be invoked (see below). The values given below may be or’d together.


Flags

  • TM_HTTPD_USER_CT_STATIC
    Call the user’s function when serving a static page with an unrecognized file extension.
  • TM_HTTPD_USER_CT_CGI
    Call the user’s function when serving a CGI page.
  • TM_HTTPD_USER_CT_ALWAYS
    Call the user’s function every time a page is served.


Returns

  • TM_ENOERROR
    Successful
  • TM_EINVAL
    Invalid server handle or length


Table of Contents >> Application Reference >> Web Server