xsharp.eu • HTTPExtensionContext - ReadClient
Page 1 of 1

HTTPExtensionContext - ReadClient

Posted: Sat Jun 08, 2024 2:13 am
by JKCanada604
Good day to you all,

I am hoping that someone might be able to help me as I have been going around in circles – now I feel like Scotty on the enterprise … a comment he made on a show when asked why they were not nearing their destination… going fast but in circles …

I am difficulty getting the extra data which one accesses by calling the ReadClient (PCALL) function.

nQuery := pECB.cbTotalBytes - pECB.cbAvailable

The first block (pECB.cbAvailable)is a no brainer however getting the data from anything above pECB.cbAvailable is proving to be problematic.

The data from ReadClient is missing some rows and even after lots of fiddling with the pointer to the buffer (ptrTemp += pECB.cbAvailable) nothing seems to get the correct result.




I wrote the code on my own and got these kinds of results with variations according to the cargo size ( .img ).

So, I went digging around and found something included below by the famous “UH”

Unfortunately, his SDK example does exactly the same thing ( the illustration above is from his code ).

This is quite the little mystery ….

Thanks everyone for just looking at this…

Cheers, JK

//-------------------------------------------------------------------------------------------------------
METHOD Init(pContext) CLASS HTTPExtensionContext
LOCAL pszData AS PSZ
LOCAL ptrTemp AS BYTE PTR
LOCAL cTemp AS STRING
LOCAL nQuery AS DWORD
LOCAL lSuccess AS LOGIC
LOCAL i,n AS DWORD
LOCAL aTemp AS ARRAY

IF (IsPtr(pContext)) .AND. (pContext != NULL_PTR)
SELF:pECB := pContext
SELF:StatusCode := 0
SELF:nError := 0

SUPER:Init()

/*
* If the request is a GET, then the lpszQueryString member of the ECB contains the query string. If the request is
* a POST, then you have to get all of the data, both from the lpbData member, and then read the rest of the data
* via the ReadClient() call.
*/
SELF:cMethod := Upper(Psz2String(pECB.lpszMethod))

IF SELF:cMethod = HTTP_POST
IF pECB.cbTotalBytes > 0
ptrTemp := MemAlloc(pECB.cbTotalBytes)

IF ptrTemp = NULL_PTR
SELF:nError := HSE_STATUS_ERROR
RETURN SELF
ENDIF

MemCopy(ptrTemp, pECB.lpbData, PszLen(pECB.lpbData) + 1 )

nQuery := pECB.cbTotalBytes - pECB.cbAvailable

pszData := ptrTemp

IF nQuery > 0
pszData := ptrTemp
ptrTemp += pECB.cbAvailable
SELF:ReadClient(ptrTemp, nQuery)
ENDIF
lSuccess := TRUE
ENDIF

cTemp := Psz2String(pszData)

IF lSuccess
// UH 02/18/1999
nQuery := SLen(cTemp)
IF nQuery > 1
IF SubStr2(cTemp, nQuery-1) == CRLF
cTemp := SubStr3(cTemp, 1, nQuery - 2)
ENDIF
ENDIF

SELF:aPostValues := SELF:__GetValues(cTemp)

// UH 08/28/2000
SELF:cPostStream := cTemp
ENDIF
ENDIF

SELF:cQueryString := Psz2String(pECB.lpszQueryString)

n := ALen(SELF:aPostValues)
FOR i := 1 TO n
aTemp := ArrayCreate(2)
aTemp[1] := SELF:aPostValues[i,1]
aTemp[2] := SELF:aPostValues[i,2]
AAdd(SELF:aArgs, aTemp)
NEXT

SELF:cPath := SELF:GetServerVariable("PATH_TRANSLATED")
ELSE
SUPER:Init()
SELF:nError := 0xFFFFFFFF
ENDIF

// UH 09/12/2000 Let the user decide to use cookies or not
// SELF:ReadCookies()

RETURN SELF