MCPcopy Create free account
hub / github.com/mhammond/pywin32 / ReadClient

Method ReadClient

isapi/src/PyExtensionObjects.cpp:511–561  ·  view source on GitHub ↗

@pymethod string|EXTENSION_CONTROL_BLOCK|ReadClient|

Source from the content-addressed store, hash-verified

509
510// @pymethod string|EXTENSION_CONTROL_BLOCK|ReadClient|
511PyObject * PyECB::ReadClient(PyObject *self, PyObject *args)
512{
513 PyECB * pecb = (PyECB *) self;
514 if (!pecb || !pecb->Check()) return NULL;
515
516 BOOL bRes = FALSE;
517 BYTE * pBuff = NULL;
518 DWORD nSize = pecb->m_totalBytes - pecb->m_available;
519 // @pyparm int|nbytes||Default is to read all available data.
520 if (!PyArg_ParseTuple(args, "|l:ReadClient", &nSize))
521 return NULL;
522 Py_BEGIN_ALLOW_THREADS
523 assert (nSize >= 0); // DWORD == unsigned == >= 0
524
525 DWORD orgSize = nSize;
526 DWORD bytesGot= nSize;
527
528 pBuff = new BYTE[nSize];
529 bRes = pecb->m_pcb->ReadClient(pBuff, &bytesGot);
530 if (bytesGot<orgSize){
531 DWORD extraBytes = orgSize-bytesGot;
532 DWORD offset=bytesGot;
533 while (extraBytes > 0){
534 bytesGot=extraBytes;
535 bRes = pecb->m_pcb->ReadClient(&pBuff[offset], &bytesGot);
536 if (bytesGot <1)
537 break;
538
539 extraBytes -= bytesGot;
540 offset += bytesGot;
541 }
542 if (extraBytes>0)
543 nSize -= extraBytes;
544 }
545
546 Py_END_ALLOW_THREADS
547 if (!bRes){
548 delete [] pBuff;
549 return SetPyECBError("ReadClient");
550 }
551
552 PyObject * pyRes = NULL;
553 if (nSize>0)
554 pyRes =PyString_FromStringAndSize((const char *)pBuff, nSize);
555 else
556 pyRes = PyString_FromStringAndSize("", 0);
557
558 delete [] pBuff;
559
560 return pyRes;
561}
562
563// The following are wrappers for the various ServerSupportFunction
564// @pymethod |EXTENSION_CONTROL_BLOCK|SendResponseHeaders|Calls ServerSupportFunction with HSE_REQ_SEND_RESPONSE_HEADER_EX

Callers

nothing calls this directly

Calls 2

SetPyECBErrorFunction · 0.85
CheckMethod · 0.45

Tested by

no test coverage detected