Oharra
Baimena behar duzu orria atzitzeko. Direktorioetan saioa has dezakezu edo haiek alda ditzakezu.
Baimena behar duzu orria atzitzeko. Direktorioak alda ditzakezu.
Recupera la siguiente notificación para el host del módulo actual.
Sintaxis
virtual BOOL GetNextNotification(
IN REQUEST_NOTIFICATION_STATUS status,
OUT DWORD* pdwNotification,
OUT BOOL* pfIsPostNotification,
OUT CHttpModule** ppModuleInfo,
OUT IHttpEventProvider** ppRequestOutput
) = 0;
Parámetros
status
[IN] El REQUEST_NOTIFICATION_STATUS valor de enumeración que se va a devolver de la notificación actual.
pdwNotification
[OUT] Puntero a un DWORD objeto que contiene el valor de máscara de bits para la siguiente notificación.
pfIsPostNotification
[OUT] Puntero a un valor booleano.
true para indicar que la notificación es una notificación posterior; de lo contrario, false.
ppModuleInfo
[OUT] Puntero a la dirección de la clase CHttpModule que es responsable de procesar la notificación devuelta.
ppRequestOutput
[OUT] Puntero a la dirección de la interfaz IHttpEventProvider para la notificación devuelta.
Valor devuelto
true si la llamada a GetNextNotification se realizó correctamente; de lo contrario, false.
Comentarios
Los módulos HTTP pueden usar el GetNextNotification método para combinar notificaciones dentro del mismo host de módulo. Devolver el procesamiento a la canalización integrada de procesamiento de solicitudes requiere una pequeña cantidad de sobrecarga. Para omitir esa sobrecarga, un módulo HTTP puede llamar al GetNextNotification método para pasar a la siguiente notificación y continuar el procesamiento, siempre que las dos notificaciones estén dentro del mismo host del módulo y no se registre ningún controlador de notificaciones adicional para procesar una solicitud entre notificaciones.
Por ejemplo, un módulo HTTP podría contener un método OnResolveRequestCache y otro módulo HTTP dentro del mismo host de módulo podría contener un método OnPostResolveRequestCache . El primer módulo puede llamar al GetNextNotification método para continuar el procesamiento, en lugar de devolver el procesamiento a la canalización, como si el módulo ya se hubiera registrado para el método de notificación posterior al OnPostResolveRequestCache evento.
Nota
Si la llamada a GetNextNotification devuelve false, puede habilitar una regla failed-request-tracing que le permitirá examinar las notificaciones que IIS está procesando.
Ejemplo
En el ejemplo de código siguiente se muestra cómo crear un módulo HTTP que realice las tareas siguientes:
Se registra para varias notificaciones.
Crea un método auxiliar que llama al
GetNextNotificationmétodo , que intenta saltar a la siguiente notificación.Para cada notificación registrada, define controladores de notificaciones que llaman al método auxiliar y, a continuación, muestra el estado devuelto al cliente.
#define _WINSOCKAPI_
#include <windows.h>
#include <sal.h>
#include <httpserv.h>
// Create the module class.
class MyHttpModule : public CHttpModule
{
public:
REQUEST_NOTIFICATION_STATUS
OnBeginRequest(
IN IHttpContext * pHttpContext,
IN IHttpEventProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pProvider );
// Clear the existing response.
pHttpContext->GetResponse()->Clear();
// Set the MIME type to plain text.
pHttpContext->GetResponse()->SetHeader(
HttpHeaderContentType,"text/plain",
(USHORT)strlen("text/plain"),TRUE);
// Return processing to the pipeline.
return RQ_NOTIFICATION_CONTINUE;
}
REQUEST_NOTIFICATION_STATUS
OnAuthenticateRequest(
IN IHttpContext * pHttpContext,
IN IAuthenticationProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pProvider );
// Attempt to retrieve the next notification and display the result.
GetNotificationAndDisplayResult(
pHttpContext,"OnAuthenticateRequest\n");
// Return processing to the pipeline.
return RQ_NOTIFICATION_CONTINUE;
}
REQUEST_NOTIFICATION_STATUS
OnPostAuthenticateRequest(
IN IHttpContext * pHttpContext,
IN IHttpEventProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pProvider );
// Attempt to retrieve the next notification and display the result.
GetNotificationAndDisplayResult(
pHttpContext,"\nOnPostAuthenticateRequest\n");
// Return processing to the pipeline.
return RQ_NOTIFICATION_CONTINUE;
}
REQUEST_NOTIFICATION_STATUS
OnAuthorizeRequest(
IN IHttpContext * pHttpContext,
IN IHttpEventProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pProvider );
// Attempt to retrieve the next notification and display the result.
GetNotificationAndDisplayResult(
pHttpContext,"\nOnAuthorizeRequest\n");
// Return processing to the pipeline.
return RQ_NOTIFICATION_CONTINUE;
}
REQUEST_NOTIFICATION_STATUS
OnPostAuthorizeRequest(
IN IHttpContext * pHttpContext,
IN IHttpEventProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pProvider );
// Attempt to retrieve the next notification and display the result.
GetNotificationAndDisplayResult(
pHttpContext,"\nOnPostAuthorizeRequest\n");
// Return processing to the pipeline.
return RQ_NOTIFICATION_CONTINUE;
}
REQUEST_NOTIFICATION_STATUS
OnMapRequestHandler(
IN IHttpContext * pHttpContext,
IN IMapHandlerProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pHttpContext );
UNREFERENCED_PARAMETER( pProvider );
// End additional processing.
return RQ_NOTIFICATION_FINISH_REQUEST;
}
private:
// Create a helper method that attempts to retrieve the next
// notification and returns the status to a Web client.
void GetNotificationAndDisplayResult(
IHttpContext * pHttpContext,
PCSTR pszBuffer
)
{
DWORD dwNotification = 0;
BOOL fPostNotification = FALSE;
CHttpModule * pHttpModule = NULL;
IHttpEventProvider * pEventProvider = NULL;
char szBuffer[256]="";
// Attempt to retrive the next notification.
BOOL fReturn = pHttpContext->GetNextNotification(
RQ_NOTIFICATION_CONTINUE,
&dwNotification,&fPostNotification,
&pHttpModule,&pEventProvider);
// Return the name of the notification to a Web client.
WriteResponseMessage(pHttpContext,pszBuffer);
// Return the status of the GetNextNotification method to a Web client.
sprintf_s(szBuffer,255,"\tGetNextNotification return value: %s\n",
fReturn==TRUE?"true":"false");
WriteResponseMessage(pHttpContext,szBuffer);
// Return the notification bitmask to a Web client.
sprintf_s(szBuffer,255,"\tNotification: %08x\n",dwNotification);
WriteResponseMessage(pHttpContext,szBuffer);
// Return whether the notification is a post-notification.
sprintf_s(szBuffer,255,"\tPost-notification: %s\n",
fPostNotification==TRUE?"Yes":"No");
WriteResponseMessage(pHttpContext,szBuffer);
}
// Create a utility method that inserts a string value into the response.
HRESULT WriteResponseMessage(
IHttpContext * pHttpContext,
PCSTR pszBuffer
)
{
// Create an HRESULT to receive return values from methods.
HRESULT hr;
// Create a data chunk. (Defined in the Http.h file.)
HTTP_DATA_CHUNK dataChunk;
// Set the chunk to a chunk in memory.
dataChunk.DataChunkType = HttpDataChunkFromMemory;
// Buffer for bytes written of data chunk.
DWORD cbSent;
// Set the chunk to the buffer.
dataChunk.FromMemory.pBuffer =
(PVOID) pszBuffer;
// Set the chunk size to the buffer size.
dataChunk.FromMemory.BufferLength =
(USHORT) strlen(pszBuffer);
// Insert the data chunk into the response.
hr = pHttpContext->GetResponse()->WriteEntityChunks(
&dataChunk,1,FALSE,TRUE,&cbSent);
// Test for an error.
if (FAILED(hr))
{
// Return the error status.
return hr;
}
// Return a success status.
return S_OK;
}
};
// Create the module's class factory.
class MyHttpModuleFactory : public IHttpModuleFactory
{
public:
HRESULT
GetHttpModule(
OUT CHttpModule ** ppModule,
IN IModuleAllocator * pAllocator
)
{
UNREFERENCED_PARAMETER( pAllocator );
// Create a new instance.
MyHttpModule * pModule = new MyHttpModule;
// Test for an error.
if (!pModule)
{
// Return an error if we cannot create the instance.
return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
}
else
{
// Return a pointer to the module.
*ppModule = pModule;
pModule = NULL;
// Return a success status.
return S_OK;
}
}
void Terminate()
{
// Remove the class from memory.
delete this;
}
};
// Create the module's exported registration function.
HRESULT
__stdcall
RegisterModule(
DWORD dwServerVersion,
IHttpModuleRegistrationInfo * pModuleInfo,
IHttpServer * pGlobalInfo
)
{
UNREFERENCED_PARAMETER( dwServerVersion );
UNREFERENCED_PARAMETER( pGlobalInfo );
return pModuleInfo->SetRequestNotifications(
new MyHttpModuleFactory,
RQ_BEGIN_REQUEST | RQ_AUTHENTICATE_REQUEST |
RQ_AUTHORIZE_REQUEST | RQ_MAP_REQUEST_HANDLER,
RQ_AUTHENTICATE_REQUEST | RQ_AUTHORIZE_REQUEST
);
}
El módulo debe exportar la función RegisterModule . Puede exportar esta función mediante la creación de un archivo de definición de módulo (.def) para el proyecto, o bien puede compilar el módulo mediante el /EXPORT:RegisterModule modificador . Para obtener más información, vea Tutorial: Creación de un módulo HTTP de Request-Level mediante código nativo.
Opcionalmente, puede compilar el código mediante la __stdcall (/Gz) convención de llamada en lugar de declarar explícitamente la convención de llamada para cada función.
Requisitos
| Tipo | Descripción |
|---|---|
| Remoto | - IIS 7.0 en Windows Vista - IIS 7.5 en Windows 7 - IIS 8.0 en Windows 8 - IIS 10.0 en Windows 10 |
| Servidor | - IIS 7.0 en Windows Server 2008 - IIS 7.5 en Windows Server 2008 R2 - IIS 8.0 en Windows Server 2012 - IIS 8.5 en Windows Server 2012 R2 - IIS 10.0 en Windows Server 2016 |
| Producto | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - IIS Express 7.5, IIS Express 8.0, IIS Express 10.0 |
| Encabezado | Httpserv.h |