Reputation: 66590
I have shiny web app and I want to test my code for 500 errors from API. My app is using httr library. I've set this in fiddler:
static function OnBeforeResponse(oSession: Session) {
if (m_Hide304s && oSession.responseCode == 304) {
oSession["ui-hide"] = "true";
}
if (oSession.url.Contains("study.xml")) {
oSession.oResponse.headers.HTTPResponseCode = 500;
oSession.oResponse.headers.Add("Foo", "Bar");
}
}
and in R code I have this:
path <- paste0(
url,
"/study.xml/", .session$sid, "/analysis_data"
)
res <- GET(path, use_proxy("127.0.0.1", 8888))
print(paste(path, res$status_code))
print(json(headers(res)))
if (res$status_code == 500) {
# handler error
stop("error 500")
}
Even that I have 500 for the response in Fiddler, in R I have 200, the header is set correctly and when the page return 404 I get 404 response.
Is there other way to simulate 500 error code in fiddler? I find Fiddler script to be simplest, because I don't need to fiddle with Fiddler interface.
Upvotes: 1
Views: 986
Reputation: 66590
Found It, I needed to use:
oSession.oRequest.FailSession(500, "Blocked", "Fiddler blocked this request");
Upvotes: 2