Skip to content

Latest commit

 

History

History
104 lines (73 loc) · 6.57 KB

File metadata and controls

104 lines (73 loc) · 6.57 KB
title IHttpServer::GetFileInfo Method
description Learn how the GetFileInfo method returns an IHttpFileInfo interface for a specific file path.
ms.date 10/07/2016
ms.assetid 1c3d91fe-062b-93c1-c5ad-e0dda028d987

IHttpServer::GetFileInfo Method

Returns an IHttpFileInfo interface for a specific file path.

Syntax

virtual HRESULT GetFileInfo(  
   IN PCWSTR pszPhysicalPath,  
   IN HANDLE hUserToken,  
   IN PSID pSid,  
   IN PCWSTR pszVrPath,  
   IN HANDLE hVrToken,  
   IN BOOL fCache,  
   OUT IHttpFileInfo** ppFileInfo,  
   IN IHttpTraceContext* pHttpTraceContext = NULL  
) = 0;  

Parameters

pszPhysicalPath
[IN] A pointer to a string that contains the physical path to a file.

hUserToken
[IN] A HANDLE that contains the token for the impersonation user; otherwise, NULL.

pSid
[IN] A pointer to a security identifier (SID) that contains the security ID for the impersonation user; otherwise, NULL.

pszVrPath
[IN] A pointer to a string that contains the virtual path to register for change notifications; otherwise, NULL.

hVrToken
[IN] A HANDLE that contains the impersonation token to register for change notifications; otherwise, NULL.

fCache
[IN] true to indicate that the file should be cached; otherwise, false.

ppFileInfo
[OUT] A dereferenced pointer to an IHttpFileInfo interface.

pHttpTraceContext
[IN] A pointer to an optional IHttpTraceContext interface.

Return Value

An HRESULT. Possible values include, but are not limited to, those in the following table.

Value Definition
S_OK Indicates that the operation was successful.
E_FAIL Indicates that the call to GetFileInfo was made while the module host was terminating.

Remarks

The IHttpServer::GetFileInfo method creates an IHttpFileInfo interface for a specific path. This method differs from the IHttpContext::GetFileInfo method, which returns an IHttpFileInfo interface for the file that IIS is processing within a request context.

The pszPhysicalPath and ppFileInfo parameters are required to create an IHttpFileInfo interface. The pszPhysicalPath parameter specifies the path to the file, and the ppFileInfo parameter defines the pointer that IIS will populate with the corresponding IHttpFileInfo interface.

The pszVrPath and hVrToken parameters are optional, and you should set them to NULL if you do not use them. These parameters specify, respectively, the virtual path and impersonation token to use when a module registers for change notifications (for example, if you request caching by setting the fCache parameter to true).

Note

Other configuration settings may prevent IIS from caching the file, even if you specify true for the fCache parameter.

The hUserToken and pSid parameters are also optional, and you should set them to NULL if you do not use them. These parameters specify, respectively, the token and SID for the impersonation user. The remaining optional parameter, pHttpTraceContext, specifies the IHttpTraceContext interface for tracing.

Example

The following code example demonstrates how to create an HTTP module that performs the following tasks:

  1. Registers for the RQ_BEGIN_REQUEST notification.

  2. Creates a CHttpModule class that contains an OnBeginRequest method. When a client requests a file, the OnBeginRequest method performs the following tasks:

    1. Maps a path to a relative URL by using the IHttpContext::MapPath method.

    2. Creates an IHttpFileInfo interface for the file path by using the IHttpServer::GetFileInfo method.

    3. Retrieves the entity tag for the file by using the IHttpFileInfo::GetETag method.

    4. Returns the entity tag to the client by using the IHttpResponse::WriteEntityChunks method.

  3. Removes the CHttpModule class from memory and then exits.

[!code-cppIHttpServerGetFileInfo#1]

For more information on how to create and deploy a native DLL module, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.

You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.

Requirements

Type Description
Client - IIS 7.0 on [!INCLUDEwinvista]
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on [!INCLUDEwinsrv2008]
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100]
Header Httpserv.h

See Also

IHttpServer Interface
IHttpContext::GetFileInfo Method