REBOL [
Title: "Etsy HTTP Hack"
Date: 18-Sep-2012
Author: "Christopher Ross-Gill"
]
use [fail-at][
fail-at: do bind [
remove-each [code response] response-actions [find [400 403 404 500] code]
append response-actions [400 fail-at 403 fail-at 404 fail-at 500 fail-at]
[
headers: make string! 500
while [ ( line: pick port/sub-port 1 ) <> "" ] [
append headers join line "^/"
use [mk][
if parse/all line ["X-Error-Detail:" mk: to end][
append response-line back mk
]
]
] ; remove the headers
system/words/close port/sub-port
net-error response-line
port/status: 'file
]
] last second get in system/schemes/http/handler 'open
]