Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read non success http data in rebol

Tags:

rebol

red

Is there a way to read non success http data, for example for a 404, in Rebol? When open gets a non success http response code for an URL it fails with an error, but I would like to read the response instead.

like image 576
rnyberg Avatar asked Oct 01 '22 04:10

rnyberg


1 Answers

I know this is crude, but it works for Rebol 2. You can get the http protocol scheme with

 h: get in system/schemes 'http

then you write it to a file

write %ht mold h

and edit this file. There you replace this line

result: select either tunnel [tunnel-actions] [response-actions] response-code 

with

port/status: response-code 
result: case [
    tunnel [
       select tunnel-actions  response-code 
    ]
    not find response-actions response-code [
       return response-code
    ] 
    true [
      select response-actions response-code 
   ]
]

Then you have to replace the original scheme. Add
Rebol [] system/schemes/http:
at the beginnung of your ht-file and do it with do %ht

like image 196
sqlab Avatar answered Oct 05 '22 12:10

sqlab