Extracting binary response from HTTP call within Omnis
andyh at totallybrilliant.com
Sun Nov 6 22:24:55 UTC 2022
Trying to extract a binary file from an HTTP response from an Omnis method HTTP call…..the call (when made in a browser) simply spits back an excel file, and that’s what I am trying to get back here !
I use :
HTTPGet (lvHost,lvURI) Returns SocketNum
To initiate the connection and get my socket, all good.
Then I have 2 calls going on (more just for testing here !) :
HTTPPage (URL) Returns PageContent
HTTPRead (SocketNum,lvBuffer) Returns lvByteCount
In the first line - that issues the call that I want to make to the server and I get a text based response in PageContent that starts with :
HTTP/1.1 200 OK
Date: Sun, 06 Nov 2022 22:07:00 GMT
Server: WSGIServer/0.2 CPython/3.9.7
And then it appears to have the attachment - presumably as a binary but of course in text its gobbledy gook - not sure if I can extract the binary from the text here ?
The second one (HTTPRead) returns a binary field (lvBuffer) that ‘looks’ like it may have the binary file I want plus a little bit more (I am suspecting it is actually the same as the HTTPPage response but as a binary field ??)
My guess is that the actual binary file that I am interested in follows a known binary string in the binary field returned (like maybe after headerEndString - chartoutf8(chr(13,10,13,10)) ) - but this is where my knowledge comes to an end ! Does anyone have knowledge of the make up of HTTPRead binary ?? i.e. if I can use something like :
Calculate lvBuffer as bytemid(lvBuffer,binsearch(headerEndString,lvBuffer)+4,binlength(lvBuffer))
To get my actual binary file being returned…..
I’m good when I get it - just need to get it :)
Any and all help appreciated…..
Totally Brilliant Software Inc
Phone (US) : (863) 409 4870
Phone (UK) : 0207 193 8582
Web : www.totallybrilliant.com
Helpdesk : http://totallybrilliant.kayako.com
Email : andyh at totallybrilliant.com
More information about the omnisdev-en