Good morning/night!,
So I have this little issue when running this little service I'm doing to download files via URL, text part is working correct but when I try to download an image, the image gets corrupted or something because when you open it, it has like a dizzy effect or its green and red directly.
I stracted a little code to test the image download which is the following:
URL='http://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png'
DIR.RESPUESTA='COMGATEWAY'
NOM.FICH.RESP='logo.png'
HTTP.STATUS=''
TIME.OUT='1000'
DATOS.RESPUESTA=''
CABECERA.RESPUESTA=''
RESPUESTA=createRequest(URL,'GET',HTTP.HANDLER)
RESPUESTA=submitRequest(HTTP.HANDLER,TIME.OUT,'',CABECERA.RESPUESTA,DATOS.RESPUESTA,HTTP.STATUS)
CRT 'KG.HTTP: HTTP.STATUS [':HTTP.STATUS:'] ':TIME()
* Checks HTTP status
IF HTTP.STATUS<1,1>#'200' THEN
* Msg 'La respuesta del servidor no ha sido correcta. %1'
CALL GENMENSAJE(64746,HTTP.STATUS<1,1>,'T',NOM.SUB,MSG.ERROR)
END
* WRITES THE DATA IN THE FILE logo.png
IF DATOS.RESPUESTA#'' THEN
CALL QOPEN(DIR.RESPUESTA,FICHERO,'')
WRITE DATOS.RESPUESTA ON FICHERO,NOM.FICH.RESP
DATOS.RESPUESTA=''
END
This is the output:
KG.HTTP: HTTP.STATUS [200²OK] 45952.5254
Also it is returning this hearder:
KG.HTTP: CABECERA.RESPUESTA [Accept-Ranges²bytes¦Content-Type²image/png¦Cross-Origin-Resource-Policy²cross-origin¦Cross-Origin-Opener-Policy-Report-Only²same-origin; report-to="static-on-bigtable"¦Report-To²{"group":"static-on-bigtable","max_age":2592000,"endpoints":[{"url":"https://csp.withgoogle.com/csp/report-to/static-on-bigtable"}]}¦Content-Length²3501¦Date²Tue, 09 Aug 2022 10:57:29 GMT¦Expires²Tue, 09 Aug 2022 10:57:29 GMT¦Cache-Control²private, max-age=31536000¦Last-Modified²Tue, 22 Oct 2019 18:30:00 GMT¦X-Content-Type-Options²nosniff¦Server²sffe¦X-XSS-Protection²0] 46649.6447
An this is the image:
(The backgroud is edited and changed to this blue color you can see, because the original backgroud is white and the letters are also white)
Its possible that I'm missing something in the request maybe?, Could be that the WRITE of the data output is writing something wrong because of the encoding or something that I'm not controling / sending in the request?
Would appreciate your help,
Best regards!