mod_isapi.c revision 1551393ba920a6c7ff283dd2b1d24e4651b7fc05
842ae4bd224140319ae7feec1872b93dfd491143fielding/* ====================================================================
842ae4bd224140319ae7feec1872b93dfd491143fielding * The Apache Software License, Version 1.1
842ae4bd224140319ae7feec1872b93dfd491143fielding * Copyright (c) 2000 The Apache Software Foundation. All rights
842ae4bd224140319ae7feec1872b93dfd491143fielding * reserved.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * Redistribution and use in source and binary forms, with or without
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * modification, are permitted provided that the following conditions
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 1. Redistributions of source code must retain the above copyright
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * notice, this list of conditions and the following disclaimer.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 2. Redistributions in binary form must reproduce the above copyright
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * notice, this list of conditions and the following disclaimer in
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * the documentation and/or other materials provided with the
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * distribution.
1723d9ccdd3b647f5b7bae44cab9ab3eca7a4874dougm * 3. The end-user documentation included with the redistribution,
59b96ad34c087942eea06884c97d12c2796a977amturk * if any, must include the following acknowledgment:
c0a549c3f6e8edc87e921cf76fac95d04feba72bwrowe * "This product includes software developed by the
2555a6b5da21d61804f47084d8fcc98eb4acbc42wrowe * Apache Software Foundation (http://www.apache.org/)."
2555a6b5da21d61804f47084d8fcc98eb4acbc42wrowe * Alternately, this acknowledgment may appear in the software itself,
70535d6421eb979ac79d8f49d31cd94d75dd8b2fjorton * if and wherever such third-party acknowledgments normally appear.
2555a6b5da21d61804f47084d8fcc98eb4acbc42wrowe * 4. The names "Apache" and "Apache Software Foundation" must
2555a6b5da21d61804f47084d8fcc98eb4acbc42wrowe * not be used to endorse or promote products derived from this
79d97c2c5e2d3f8bb2a92cd21b3b4900d7bf04d6mturk * software without prior written permission. For written
79d97c2c5e2d3f8bb2a92cd21b3b4900d7bf04d6mturk * permission, please contact apache@apache.org.
79d97c2c5e2d3f8bb2a92cd21b3b4900d7bf04d6mturk * 5. Products derived from this software may not be called "Apache",
2555a6b5da21d61804f47084d8fcc98eb4acbc42wrowe * nor may "Apache" appear in their name, without prior written
1723d9ccdd3b647f5b7bae44cab9ab3eca7a4874dougm * permission of the Apache Software Foundation.
e9501b71b8a1e76384cb010b1e41e76a1e47aacctrawick * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
e9501b71b8a1e76384cb010b1e41e76a1e47aacctrawick * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
6335eb31f0f0ed54628a04ed32946360b8b77684minfrin * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * SUCH DAMAGE.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * ====================================================================
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * This software consists of voluntary contributions made by many
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * individuals on behalf of the Apache Software Foundation. For more
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * information on the Apache Software Foundation, please see
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * Portions of this software are based upon public domain software
eee895b02dd7867622afd0a8a94f2efc7de9c618wrowe * originally written at the National Center for Supercomputing Applications,
eee895b02dd7867622afd0a8a94f2efc7de9c618wrowe * University of Illinois, Urbana-Champaign.
38fd849bd99e2765ee633b6dc576b5f17acdc455wrowe * mod_isapi.c - Internet Server Application (ISA) module for Apache
38fd849bd99e2765ee633b6dc576b5f17acdc455wrowe * by Alexei Kosut <akosut@apache.org>
90f18725dbb9bdfba94da22aa60f94dfb759a8ferpluem * This module implements Microsoft's ISAPI, allowing Apache (when running
38fd849bd99e2765ee633b6dc576b5f17acdc455wrowe * under Windows) to load Internet Server Applications (ISAPI extensions).
9f1a88897168c3f1e5009acb585daf01e38a0299jim * It implements all of the ISAPI 2.0 specification, except for the
9f1a88897168c3f1e5009acb585daf01e38a0299jim * "Microsoft-only" extensions dealing with asynchronous I/O. All ISAPI
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk * extensions that use only synchronous I/O and are compatible with the
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim * ISAPI 2.0 specification should work (most ISAPI 1.0 extensions should
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim * function as well).
38fd849bd99e2765ee633b6dc576b5f17acdc455wrowe * To load, simply place the ISA in a location in the document tree.
38fd849bd99e2765ee633b6dc576b5f17acdc455wrowe * Then add an "AddHandler isapi-isa dll" into your config file.
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk * You should now be able to load ISAPI DLLs just be reffering to their
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk * URLs. Make sure the ExecCGI option is active in the directory
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk * the ISA is in.
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim/* We use the exact same header file as the original */
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk/* TODO: Unknown errors that must be researched for correct codes */
1dac466bcc84f8ebf410016dcf2a4cd4312e8611wrowe/* Seems IIS does not enforce the requirement for \r\n termination on HSE_REQ_SEND_RESPONSE_HEADER,
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim define this to conform */
38fd849bd99e2765ee633b6dc576b5f17acdc455wrowe/* Declare the ISAPI functions */
1dac466bcc84f8ebf410016dcf2a4cd4312e8611wroweBOOL WINAPI GetServerVariable (HCONN hConn, LPSTR lpszVariableName,
38fd849bd99e2765ee633b6dc576b5f17acdc455wroweBOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
38fd849bd99e2765ee633b6dc576b5f17acdc455wroweBOOL WINAPI ReadClient (HCONN ConnID, LPVOID lpvBuffer, LPDWORD lpdwSize);
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturkBOOL WINAPI ServerSupportFunction (HCONN hConn, DWORD dwHSERequest,
1dac466bcc84f8ebf410016dcf2a4cd4312e8611wrowe The optimiser blows it totally here. What happens is that autos are addressed relative to the
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim stack pointer, which, of course, moves around. The optimiser seems to lose track of it somewhere
38fd849bd99e2765ee633b6dc576b5f17acdc455wrowe between setting HttpExtensionProc's address and calling through it. We work around the problem by
9621e4c4056383e4a2b844b14687bae500b33a82wrowe forcing it to use frame pointers.
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk The revisions below may eliminate this artifact.
90f18725dbb9bdfba94da22aa60f94dfb759a8ferpluem/* Our loaded isapi module description structure */
61d82a1991928d3fa5ee50dc57f2ae3f4b5c781ajimtypedef struct {
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim/* Our "Connection ID" structure */
1dac466bcc84f8ebf410016dcf2a4cd4312e8611wrowetypedef struct {
41c38e78e8e5dc73544571cc2b749d40869e84fawrowe /* Use similar restrictions as CGIs
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim * If this fails, it's pointless to load the isapi dll.
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim /* Load the module
b842b65e0618c5535233b197f03dc917d184adb3jim * TODO: Critical section
b842b65e0618c5535233b197f03dc917d184adb3jim * Warning: cid should not be allocated from pool if we
eee895b02dd7867622afd0a8a94f2efc7de9c618wrowe * cache the isapi process in-memory.
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk * This code could use cacheing... everything that follows
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim * should only be performed on the first isapi dll invocation,
1d2ff7570139286b0f0d16f92187a16ed5932291mturk * not with every HttpExtensionProc()
eee895b02dd7867622afd0a8a94f2efc7de9c618wrowe isa->pVer = ap_pcalloc(r->pool, sizeof(HSE_VERSION_INFO));
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim /* TODO: These may need to become overrideable, so that we
1d2ff7570139286b0f0d16f92187a16ed5932291mturk * assure a given isapi can be fooled into behaving well.
f73a8fabbdc4ec11c8b475e9f48539de0c4f82ebmturk isa->reportversion = MAKELONG(0, 5); /* Revision 5.0 */
f73a8fabbdc4ec11c8b475e9f48539de0c4f82ebmturk ap_log_rerror(APLOG_MARK, APLOG_ALERT, GetLastError(), r,
f73a8fabbdc4ec11c8b475e9f48539de0c4f82ebmturk (void *)(GetProcAddress(isa->handle, "GetExtensionVersion")))) {
f73a8fabbdc4ec11c8b475e9f48539de0c4f82ebmturk ap_log_rerror(APLOG_MARK, APLOG_ALERT, GetLastError(), r,
e8f95a682820a599fe41b22977010636be5c2717jim "ISAPI %s is missing GetExtensionVersion()",
07ac837c886b356dc96e83cf82fb348eb56406d9jim (void *)(GetProcAddress(isa->handle, "HttpExtensionProc")))) {
5d392744e2077f71f34ce098ab49d2c0ddcf4ea3jim ap_log_rerror(APLOG_MARK, APLOG_ALERT, GetLastError(), r,
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim "ISAPI %s is missing HttpExtensionProc()",
07ac837c886b356dc96e83cf82fb348eb56406d9jim /* TerminateExtension() is an optional interface */
07ac837c886b356dc96e83cf82fb348eb56406d9jim isa->TerminateExtension = (void *)(GetProcAddress(isa->handle, "TerminateExtension"));
5d392744e2077f71f34ce098ab49d2c0ddcf4ea3jim /* Run GetExtensionVersion() */
5d392744e2077f71f34ce098ab49d2c0ddcf4ea3jim /* ### euh... we're passing the wrong type of error code here */
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim ap_log_rerror(APLOG_MARK, APLOG_ALERT, HTTP_INTERNAL_SERVER_ERROR, r,
5d392744e2077f71f34ce098ab49d2c0ddcf4ea3jim "ISAPI %s call GetExtensionVersion() failed",
90f18725dbb9bdfba94da22aa60f94dfb759a8ferpluem /* Load of this module completed, this is the point at which *isa
90f18725dbb9bdfba94da22aa60f94dfb759a8ferpluem * could be cached for later invocation.
90f18725dbb9bdfba94da22aa60f94dfb759a8ferpluem * on to invoking this request...
188befd3a49e3a126bd801d7dc5a7f6e63ad4332mturk /* Set up variables */
f185ce14f5dd540ae54659f764989c017c619485jim /* Set up connection structure and ecb */
f185ce14f5dd540ae54659f764989c017c619485jim cid->ecb = ap_pcalloc(r->pool, sizeof(struct _EXTENSION_CONTROL_BLOCK));
90f18725dbb9bdfba94da22aa60f94dfb759a8ferpluem /* TODO: Critical section */
2f1146e06a1bfa371573a3f3fb0379448e18aaedjim // TODO: are copies really needed here?
bf3f3b52289ee37f40842fc836ff92dd202742afpquerna cid->ecb->lpszMethod = ap_pstrdup(r->pool, (char*) r->method);
eee895b02dd7867622afd0a8a94f2efc7de9c618wrowe /* Set up the callbacks */
4415d997ac73262e513c0a571bd5be4f609040bawrowe cid->ecb->ServerSupportFunction = &ServerSupportFunction;
c3dc78855363fa6e8ecfc2bb8e2927efcd31d31djfclere /* Set up client input */
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk cid->retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR);
c3dc78855363fa6e8ecfc2bb8e2927efcd31d31djfclere /* Unlike IIS, which limits this to 48k, we read the whole
cb7cf74a315df272e2ec329ce2ef1d50b82b8384jim * sucker in. I suppose this could be bad for memory if someone
c3dc78855363fa6e8ecfc2bb8e2927efcd31d31djfclere * uploaded the complete works of Shakespeare. Well, WebSite
4415d997ac73262e513c0a571bd5be4f609040bawrowe * does the same thing.
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk * But we can be smarter and read up to our 48k and then allow
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk * the ISAPI app to read further blocks as desired.
01261c7d9578aadd1891f94c8ee03f32ba51db3dmturk long to_read = atol(ap_table_get(e, "CONTENT_LENGTH"));
4415d997ac73262e513c0a571bd5be4f609040bawrowe /* Actually, let's cap it at 48k, until we figure out what
cb7cf74a315df272e2ec329ce2ef1d50b82b8384jim * to do with this... we don't want a Content-Length: 1000000000
4415d997ac73262e513c0a571bd5be4f609040bawrowe * taking out the machine.
cb7cf74a315df272e2ec329ce2ef1d50b82b8384jim if ((read = ap_get_client_block(r, cid->ecb->lpbData, to_read)) < 0) {
00b70ae978854b5eb51722cbeda99c9067b5faf2mturk /* Although its not to spec, IIS seems to null-terminate
00b70ae978854b5eb51722cbeda99c9067b5faf2mturk * its lpdData string. So we will too. To make sure
cb7cf74a315df272e2ec329ce2ef1d50b82b8384jim * cbAvailable matches cbTotalBytes, we'll up the latter
cb7cf74a315df272e2ec329ce2ef1d50b82b8384jim * and equalize them.
9e3209bc06ddf32f23e4b254faa45914bc323cc9jim cid->ecb->cbAvailable = cid->ecb->cbTotalBytes = read + 1;
1febae173a82bc2a71c3c0ba4105cf674000791bjim /* All right... try and run the sucker */
ff4ec92f5bb8d43b3ba1979ccda94f07961bf323jim /* Set the status (for logging) */
ff4ec92f5bb8d43b3ba1979ccda94f07961bf323jim /* Check for a log message - and log it */
9f22e9ea026e74271ddced44f6d54fa846ddc9bcwrowe /* Ignore the keepalive stuff; Apache handles it just fine without
d46dfdce9351f52a971777948d9b02f8fc668ff8niq * the ISA's "advice".
d46dfdce9351f52a971777948d9b02f8fc668ff8niq * Per Microsoft: "In IIS versions 4.0 and later, the return
d46dfdce9351f52a971777948d9b02f8fc668ff8niq * values HSE_STATUS_SUCCESS and HSE_STATUS_SUCCESS_AND_KEEP_CONN
9f22e9ea026e74271ddced44f6d54fa846ddc9bcwrowe * are functionally identical: Keep-Alive connections are
9f22e9ea026e74271ddced44f6d54fa846ddc9bcwrowe * maintained, if supported by the client."
d46dfdce9351f52a971777948d9b02f8fc668ff8niq * ... so we were pat all this time
d46dfdce9351f52a971777948d9b02f8fc668ff8niq /* emulating async behavior...
d46dfdce9351f52a971777948d9b02f8fc668ff8niq * Create a cid->completed event and wait on it for some timeout
d46dfdce9351f52a971777948d9b02f8fc668ff8niq * so that the app thinks is it running async.
d46dfdce9351f52a971777948d9b02f8fc668ff8niq * All async ServerSupportFunction calls will be handled through
d46dfdce9351f52a971777948d9b02f8fc668ff8niq * the registered IO_COMPLETION hook.
a652b68dea502131f70084ead7981d5fc754cd34jim ap_log_rerror(APLOG_MARK, APLOG_WARNING, APR_ENOTIMPL, r,
a652b68dea502131f70084ead7981d5fc754cd34jim "ISAPI %s asynch I/O request refused",
cb7cf74a315df272e2ec329ce2ef1d50b82b8384jim /* TODO: Now what... if this hung, then do we kill our own
a652b68dea502131f70084ead7981d5fc754cd34jim * thread to force it's death? For now leave timeout = -1
a652b68dea502131f70084ead7981d5fc754cd34jim /* end response if we have yet to do so.
38fd849bd99e2765ee633b6dc576b5f17acdc455wrowe /* TODO: log unrecognized retval for debugging
00211b036b78699ace57a6d800a52e6c2d57652fnd /* All done with the DLL... get rid of it...
00211b036b78699ace57a6d800a52e6c2d57652fnd * If optionally cached, pass HSE_TERM_ADVISORY_UNLOAD,
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard * and if it returns TRUE, unload, otherwise, cache it.
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard /* TODO: Crit section */
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddardBOOL WINAPI GetServerVariable (HCONN hConn, LPSTR lpszVariableName,
00211b036b78699ace57a6d800a52e6c2d57652fnd const char *result;
00211b036b78699ace57a6d800a52e6c2d57652fnd /* Mostly, we just grab it from the environment, but there are
00211b036b78699ace57a6d800a52e6c2d57652fnd * a couple of special cases
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding if (!strcasecmp(lpszVariableName, "UNMAPPED_REMOTE_USER")) {
50b2d068ddf98cf75622a0020cd143d379d1b235jfclere /* We don't support NT users, so this is always the same as
50b2d068ddf98cf75622a0020cd143d379d1b235jfclere * REMOTE_USER
50b2d068ddf98cf75622a0020cd143d379d1b235jfclere else if (!strcasecmp(lpszVariableName, "SERVER_PORT_SECURE")) {
50b2d068ddf98cf75622a0020cd143d379d1b235jfclere /* Apache doesn't support secure requests inherently, so
00211b036b78699ace57a6d800a52e6c2d57652fnd * we have no way of knowing. We'll be conservative, and say
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * all requests are insecure.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding /* Didn't find it */
a812b025d139f465a31c76fc02ed162ed5271b03ndBOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding int writ; /* written, actually, but why shouldn't I make up words? */
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard /* We only support synchronous writing */
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard ap_log_rerror(APLOG_MARK, APLOG_WARNING, ERROR_INVALID_PARAMETER, r,
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard if ((writ = ap_rwrite(Buffer, *lpwdwBytes, r)) == EOF) {
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding SetLastError(WSAEDISCON); /* TODO: Find the right error code */
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddardBOOL WINAPI ReadClient (HCONN ConnID, LPVOID lpvBuffer, LPDWORD lpdwSize)
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding /* TODO: If the request was a huge transmit or chunked, continue piping the
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * request here, but if it's of a sane size, continue to ...
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq /* We *should* break before this while loop ends */
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq /* Get rid of \n and \r */
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq /* End of headers */
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq /* ### euh... we're passing the wrong type of error
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq ### code here */
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq ap_log_rerror(APLOG_MARK, APLOG_ERR, HTTP_INTERNAL_SERVER_ERROR, r,
997023faa943892aae20d092044aa983c2936982niq /* Check all the special-case headers. Similar to what
997023faa943892aae20d092044aa983c2936982niq * ap_scan_script_header_err() does (see that function for
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * more detail)
e8ecc839fc57f2157ff10eba188d7aa3c0244174jim /* Nuke trailing whitespace */
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* Reset data */
df419be6d7d4b68823efa05722375552af49c2b6minfrin/* XXX: There is an O(n^2) attack possible here. */
df419be6d7d4b68823efa05722375552af49c2b6minfrinBOOL WINAPI ServerSupportFunction (HCONN hConn, DWORD dwHSERequest,
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* Set the status to be returned when the HttpExtensionProc()
df419be6d7d4b68823efa05722375552af49c2b6minfrin ap_table_set (r->headers_out, "Location", lpvBuffer);
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* Read any additional input */
df419be6d7d4b68823efa05722375552af49c2b6minfrin if (r->remaining > 0) {
df419be6d7d4b68823efa05722375552af49c2b6minfrin while (ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN));
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* Reset the method to GET */
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* Don't let anyone think there's still data */
df419be6d7d4b68823efa05722375552af49c2b6minfrin r->status_line = lpvBuffer ? lpvBuffer : ap_pstrdup(r->pool, "200 OK");
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* Now fill in the HTTP headers, and the rest of it. Ick.
df419be6d7d4b68823efa05722375552af49c2b6minfrin * lpdwDataType contains a string that has headers (in MIME
df419be6d7d4b68823efa05722375552af49c2b6minfrin * format), a blank like, then (possibly) data. We need
df419be6d7d4b68823efa05722375552af49c2b6minfrin * to parse it.
df419be6d7d4b68823efa05722375552af49c2b6minfrin * Easy case first:
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* Make a copy - don't disturb the original */
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* Parse them out, or die trying */
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard /* All the headers should be set now */
a812b025d139f465a31c76fc02ed162ed5271b03nd /* Any data left should now be sent directly */
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard /* Signal to resume the thread completing this request
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* Map a URL to a filename */
28fe44817329b1183f64e878c258962f90423a8dniq subreq = ap_sub_req_lookup_uri(ap_pstrndup(r->pool, (char *)lpvBuffer,
df419be6d7d4b68823efa05722375552af49c2b6minfrin GetFullPathName(subreq->filename, *lpdwSize - 1, (char *)lpvBuffer, NULL);
df419be6d7d4b68823efa05722375552af49c2b6minfrin /* IIS puts a trailing slash on directories, Apache doesn't */
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe /* Log lpvBuffer, of lpdwSize bytes, in the URI Query (cs-uri-query) field
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe * This code will do for now...
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe /* TODO: Emulate a completion port, if we can...
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe * Record the callback address and user defined argument...
e8f95a682820a599fe41b22977010636be5c2717jim * we will call this after any async request (e.g. transmitfile)
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe * as if the request had completed async execution.
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe * Per MS docs... HSE_REQ_IO_COMPLETION replaces any prior call
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe * to HSE_REQ_IO_COMPLETION, and lpvBuffer may be set to NULL.
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe /* Use TransmitFile... nothing wrong with that :)
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe /* ### euh... we're passing the wrong type of error code here */
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe "ISAPI asynchronous I/O not supported: %s",
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe case HSE_REQ_GET_IMPERSONATION_TOKEN: /* Added in ISAPI 4.0 */
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe /* TODO: Not quite ready for prime time yet */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding /* Map a URL to a filename */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding subreq = ap_sub_req_lookup_uri(ap_pstrndup(r->pool, (char *)lpvBuffer,
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding GetFullPathName(subreq->filename, *lpdwSize - 1, (char *)lpvBuffer, NULL);
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding /* IIS puts a trailing slash on directories, Apache doesn't */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding lpdwDataType = (LPDWORD) ap_palloc(r->pool, sizeof(HSE_URL_MAPEX_INFO));
2ceedfca3a2fdfdb5ff60ca17f030ce91f6331cbwrowe strncpy(((LPHSE_URL_MAPEX_INFO)lpdwDataType)->lpszPath,
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq /* is a combination of:
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_READ Allow for read.
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_WRITE Allow for write.
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_EXECUTE Allow for execute.
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_SSL Require SSL.
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_DONT_CACHE Don't cache (virtual root only).
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_NEGO_CERT Allow client SSL certifications.
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_REQUIRE_CERT Require client SSL certifications.
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_MAP_CERT Map SSL certification to a Windows account.
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_SSL128 Requires a 128-bit SSL.
e99dfd55d29a7b4209b814efc7270d0b74ccee74niq * HSE_URL_FLAGS_SCRIPT Allows for script execution.
2e41eca72bcc4167d1871b0941ee79845540d58eminfrin /* (LPHSE_URL_MAPEX_INFO)lpdwDataType)->cchMatchingPath
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard * (LPHSE_URL_MAPEX_INFO)lpdwDataType)->cchMatchingURL
11c3b5180e1de6776035320b012a28bb146e7b46chuck case HSE_REQ_GET_CERT_INFO_EX: /* Added in ISAPI 4.0 */
11c3b5180e1de6776035320b012a28bb146e7b46chuck case HSE_REQ_SEND_RESPONSE_HEADER_EX: /* Added in ISAPI 4.0 */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding /* TODO: Not quite ready for prime time */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding if (((LPHSE_SEND_HEADER_EX_INFO)lpvBuffer)->pszStatus
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding && ((LPHSE_SEND_HEADER_EX_INFO)lpvBuffer)->cchStatus) {
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding ((LPHSE_SEND_HEADER_EX_INFO)lpvBuffer)->cchStatus);
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding if (((LPHSE_SEND_HEADER_EX_INFO)lpvBuffer)->pszHeader
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding && ((LPHSE_SEND_HEADER_EX_INFO)lpvBuffer)->cchHeader)
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm /* Make a copy - don't disturb the original */
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard ((LPHSE_SEND_HEADER_EX_INFO)lpvBuffer)->cchHeader);
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding /* Parse them out, or die trying */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding /* ((LPHSE_SEND_HEADER_EX_INFO)lpvBuffer)->fKeepConn;
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * Now how are we about to start listening to an ISAPI's
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * idea of keeping or closing a connection? Seriously :)
a8523e2451f03f4a30030b7bda643a23a75d91demturk /* All the headers should be set now */
5babe00918c88eda487771fa6d6d4a1a19c0ced0chuck /* Any data left should now be sent directly */
35c9e4d2c0a6465746a98958ef756114834461e6minfrin case HSE_REQ_CLOSE_CONNECTION: /* Added after ISAPI 4.0 */
00b70ae978854b5eb51722cbeda99c9067b5faf2mturk case HSE_REQ_IS_CONNECTED: /* Added after ISAPI 4.0 */
e2458a81ee951feeff648c2ca5cad2c5a744d8e5mturk /* Returns True if client is connected c.f. Q188346*/
45dac0729754e413ff7c673481b219e9ab1a11f1bnicholes /* case HSE_REQ_EXTENSION_TRIGGER:
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard * Added after ISAPI 4.0?
11c3b5180e1de6776035320b012a28bb146e7b46chuck * Undocumented - from the Microsoft Jan '00 Platform SDK
e6366481b8fe06a24337f0b30b7da66cf64d6062stoddard /* TODO: log unrecognized ServerSupportCommand for debugging