From: Mark H. <mha...@us...> - 2008-05-15 10:57:05
|
Update of /cvsroot/pywin32/pywin32/isapi/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2971 Modified Files: ControlBlock.h PyExtensionObjects.cpp PyExtensionObjects.h PythonEng.cpp Log Message: Inline esb.WriteHeaders to avoid extra strlens, have exceptions correctly reflect the actual function being called and add SetFlushFlag (HSE_REQ_SET_FLUSH_FLAG) Index: PythonEng.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/PythonEng.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PythonEng.cpp 17 Jan 2007 04:40:12 -0000 1.5 --- PythonEng.cpp 15 May 2008 10:57:09 -0000 1.6 *************** *** 368,372 **** pcb->SetStatus(HSE_STATUS_ERROR); pcb->SetLogMessage(errmsg); ! pcb->WriteHeaders(_T("200 OK"), _T("Content-type: text/html\r\n\r\n"), false); pcb->WriteStream(htmlStream, strlen(htmlStream)); if (windows_error) { --- 368,379 ---- pcb->SetStatus(HSE_STATUS_ERROR); pcb->SetLogMessage(errmsg); ! HSE_SEND_HEADER_EX_INFO SendHeaderExInfo; ! SendHeaderExInfo.pszStatus = "200 OK"; ! SendHeaderExInfo.cchStatus = strlen(SendHeaderExInfo.pszStatus); ! SendHeaderExInfo.pszHeader = "Content-type: text/html\r\n\r\n"; ! SendHeaderExInfo.cchHeader = strlen(SendHeaderExInfo.pszHeader); ! SendHeaderExInfo.fKeepConn = FALSE; ! EXTENSION_CONTROL_BLOCK * ecb = pcb->GetECB(); ! ecb->ServerSupportFunction(ecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &SendHeaderExInfo, NULL,NULL); pcb->WriteStream(htmlStream, strlen(htmlStream)); if (windows_error) { Index: ControlBlock.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/ControlBlock.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ControlBlock.h 7 Mar 2007 01:52:46 -0000 1.5 --- ControlBlock.h 15 May 2008 10:57:09 -0000 1.6 *************** *** 39,63 **** } - DWORD WriteHeaders(LPCTSTR szStatus, LPCTSTR szHeader, const bool bKeepAlive=true) - { - // NOTE we must send Content-Length header with correct byte count - // in order for keep-alive to work, the bKeepAlive flag is not enough - // by itself.. - - HSE_SEND_HEADER_EX_INFO SendHeaderExInfo; - DWORD cchStatus = lstrlen(szStatus); - DWORD cchHeader = lstrlen(szHeader); - - // Populate SendHeaderExInfo struct - SendHeaderExInfo.pszStatus = szStatus; - SendHeaderExInfo.pszHeader = szHeader; - SendHeaderExInfo.cchStatus = cchStatus; - SendHeaderExInfo.cchHeader = cchHeader; - SendHeaderExInfo.fKeepConn = (bKeepAlive) ? TRUE:FALSE; - - // Send header - return m_pECB->ServerSupportFunction(m_pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &SendHeaderExInfo, NULL,NULL); - } - DWORD WriteStream(LPCTSTR buffer, const int buffLen, const int reserved=0) { --- 39,42 ---- Index: PyExtensionObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/PyExtensionObjects.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyExtensionObjects.h 7 Mar 2007 01:54:13 -0000 1.4 --- PyExtensionObjects.h 15 May 2008 10:57:09 -0000 1.5 *************** *** 100,103 **** --- 100,104 ---- static PyObject * MapURLToPath(PyObject *self, PyObject * args); // HSE_REQ_MAP_URL_TO_PATH static PyObject * IsKeepConn(PyObject *self, PyObject * args); // HSE_REQ_IS_KEEP_CONN + static PyObject * SetFlushFlag(PyObject *self, PyObject * args); // HSE_REQ_SET_FLUSH_FLAG static PyObject * IsSessionActive(PyObject *self, PyObject * args); Index: PyExtensionObjects.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/PyExtensionObjects.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyExtensionObjects.cpp 7 Mar 2007 01:54:13 -0000 1.7 --- PyExtensionObjects.cpp 15 May 2008 10:57:09 -0000 1.8 *************** *** 148,151 **** --- 148,152 ---- {"ReadClient", PyECB::ReadClient, 1}, // @pymeth ReadClient| {"SendResponseHeaders", PyECB::SendResponseHeaders, 1}, // @pymeth SendResponseHeaders| + {"SetFlushFlag", PyECB::SetFlushFlag, 1}, // @pymeth SetFlushFlag| {"TransmitFile", PyECB::TransmitFile, 1}, // @pymeth TransmitFile| {"MapURLToPath", PyECB::MapURLToPath, 1}, // @pymeth MapURLToPath| *************** *** 452,467 **** if (!pecb || !pecb->Check()) return NULL; // @pyparm string|reply|| // @pyparm string|headers|| // @pyparm bool|keepAlive|False| ! if (!PyArg_ParseTuple(args, "ss|i:SendResponseHeaders", &reply, &headers, &bKeepAlive)) return NULL; if (pecb->m_pcb){ Py_BEGIN_ALLOW_THREADS ! bRes = pecb->m_pcb->WriteHeaders(reply,headers,(bKeepAlive!=0)?true:false); Py_END_ALLOW_THREADS if (!bRes) ! return SetPyECBError("SendResponseHeaders"); } --- 453,478 ---- if (!pecb || !pecb->Check()) return NULL; + HSE_SEND_HEADER_EX_INFO SendHeaderExInfo; // @pyparm string|reply|| // @pyparm string|headers|| // @pyparm bool|keepAlive|False| ! if (!PyArg_ParseTuple(args, "s#s#|i:SendResponseHeaders", ! &SendHeaderExInfo.pszStatus, &SendHeaderExInfo.cchStatus, ! &SendHeaderExInfo.pszHeader, &SendHeaderExInfo.cchHeader, ! &bKeepAlive)) return NULL; + SendHeaderExInfo.fKeepConn = (bKeepAlive) ? TRUE:FALSE; if (pecb->m_pcb){ Py_BEGIN_ALLOW_THREADS ! // NOTE we must send Content-Length header with correct byte count ! // in order for keep-alive to work, the bKeepAlive flag is not enough ! // by itself.. ! // Send header ! EXTENSION_CONTROL_BLOCK * ecb = pecb->m_pcb->GetECB(); ! bRes = ecb->ServerSupportFunction(ecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &SendHeaderExInfo, NULL,NULL); Py_END_ALLOW_THREADS if (!bRes) ! return SetPyECBError("ServerSupportFunction(HSE_REQ_SEND_RESPONSE_HEADER_EX)"); } *************** *** 470,473 **** --- 481,515 ---- } + #ifndef HSE_REQ_SET_FLUSH_FLAG + // *sigh* - need a better strategy here - maybe just insist on later SDK and + // #error with a helpful message? + #pragma message("You don't appear to have a late platform SDK that supports IIS7") + #define HSE_REQ_SET_FLUSH_FLAG (HSE_REQ_END_RESERVED+43) + #endif + + // @pymethod |EXTENSION_CONTROL_BLOCK|SetFlushFlag|Calls ServerSupportFunction with HSE_REQ_SET_FLUSH_FLAG. + PyObject * PyECB::SetFlushFlag(PyObject *self, PyObject * args) + { + int f; + PyECB * pecb = (PyECB *) self; + if (!pecb || !pecb->Check()) return NULL; + + // @pyparm bool|flag|| + if (!PyArg_ParseTuple(args, "i:SetFlushFlag", &f)) + return NULL; + + if (pecb->m_pcb){ + BOOL bRes; + Py_BEGIN_ALLOW_THREADS + EXTENSION_CONTROL_BLOCK * ecb = pecb->m_pcb->GetECB(); + bRes = ecb->ServerSupportFunction(ecb->ConnID, HSE_REQ_SET_FLUSH_FLAG, (LPVOID)f, NULL,NULL); + Py_END_ALLOW_THREADS + if (!bRes) + return SetPyECBError("ServerSupportFunction(HSE_REQ_SET_FLUSH_FLAG)"); + } + Py_INCREF(Py_None); + return Py_None; + } + // @pymethod |EXTENSION_CONTROL_BLOCK|Redirect|Calls ServerSupportFunction with HSE_REQ_SEND_URL_REDIRECT_RESP PyObject * PyECB::Redirect(PyObject *self, PyObject * args) *************** *** 488,492 **** Py_END_ALLOW_THREADS if (!bRes) ! return SetPyECBError("Redirect"); } --- 530,534 ---- Py_END_ALLOW_THREADS if (!bRes) ! return SetPyECBError("ServerSupportFunction(HSE_REQ_SEND_URL_REDIRECT_RESP)"); } *************** *** 509,513 **** Py_END_ALLOW_THREADS if (!bRes) ! return SetPyECBError("GetImpersonationToken"); return PyLong_FromVoidPtr(handle); } --- 551,555 ---- Py_END_ALLOW_THREADS if (!bRes) ! return SetPyECBError("ServerSupportFunction(HSE_REQ_GET_IMPERSONATION_TOKEN)"); return PyLong_FromVoidPtr(handle); } *************** *** 526,530 **** Py_END_ALLOW_THREADS if (!bRes) ! return SetPyECBError("IsKeepCon"); return PyBool_FromLong(bIs); } --- 568,572 ---- Py_END_ALLOW_THREADS if (!bRes) ! return SetPyECBError("ServerSupportFunction(HSE_REQ_IS_KEEP_CONN)"); return PyBool_FromLong(bIs); } *************** *** 620,624 **** // ack - the completion routine will not be called - clean up! context->Cleanup(); ! return SetPyECBError("TransmitFile"); } Py_INCREF(Py_None); --- 662,666 ---- // ack - the completion routine will not be called - clean up! context->Cleanup(); ! return SetPyECBError("ServerSupportFunction(HSE_REQ_TRANSMIT_FILE)"); } Py_INCREF(Py_None); *************** *** 648,652 **** } ! // @pymethod |EXTENSION_CONTROL_BLOCK|MapURLToPath| PyObject * PyECB::MapURLToPath(PyObject *self, PyObject * args) { --- 690,694 ---- } ! // @pymethod |EXTENSION_CONTROL_BLOCK|MapURLToPath|Calls ServerSupportFunction with HSE_REQ_MAP_URL_TO_PATH PyObject * PyECB::MapURLToPath(PyObject *self, PyObject * args) { *************** *** 668,672 **** Py_END_ALLOW_THREADS if (!ok) ! return SetPyECBError("MapURLToPath"); return PyString_FromString(buffer); } --- 710,714 ---- Py_END_ALLOW_THREADS if (!ok) ! return SetPyECBError("ServerSupportFunction(HSE_REQ_MAP_URL_TO_PATH)"); return PyString_FromString(buffer); } |