I have a socket connection that is receiving an XML response from a host. The host sends the data chunked (Transfer-Encoding: chunked). I have a procedure that is reading the response and saving to file (.dat). I am able to identify and remove the http header details but have not been able to comeup with an efficient process to remove the length indicators that get passed in the data. I need to remove these so I can save teh contents to an XML file. The procedure to read the response looks as follows. I am trying to write a procedure to read the contents under c:/somefile.dat, identify the chunk length indicators and remove these from the content. Suggestions are appreciated.
Code:
PROCEDURE getResponse:
DEFINE VARIABLE vcWebResp AS LONGCHAR NO-UNDO.
DEFINE VARIABLE viBytesAvail AS INTEGER NO-UNDO.
DEFINE VARIABLE mResponse AS MEMPTR NO-UNDO.
ASSIGN viBytesAvail = vhSocket:GET-BYTES-AVAILABLE().
IF viBytesAvail = 0 THEN RETURN.
SET-SIZE(mResponse) = 0.
SET-SIZE(mResponse) = viBytesAvail.
vhSocket:READ(mResponse,1,viBytesAvail,READ-EXACT-NUM).
COPY-LOB FROM OBJECT mResponse TO vcWebResp.
ASSIGN vcFinalResp = vcFinalResp + vcWebResp.
SET-SIZE(mResponse) = 0.
END PROCEDURE.
COPY-LOB FROM OBJECT vcFinalResp TO FILE "c:/somefile.dat".