[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [meek/master] Catch NS_ERROR_NOT_AVAILABLE in reading responseStatus.
commit 38924aa574c1d6da331b69536210bad70ca95873
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Sun Feb 22 15:00:42 2015 -0800
Catch NS_ERROR_NOT_AVAILABLE in reading responseStatus.
This enables us to send a meaningful {"error": "..."} blob back to the
requestor.
---
firefox/components/main.js | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/firefox/components/main.js b/firefox/components/main.js
index f231cd6..b851d49 100644
--- a/firefox/components/main.js
+++ b/firefox/components/main.js
@@ -408,9 +408,17 @@ MeekHTTPHelper.HttpStreamListener.prototype = {
},
onStopRequest: function(req, context, status) {
// dump("onStopRequest " + status + "\n");
- let resp = {
- status: context.responseStatus,
- };
+ let resp = {};
+ try {
+ resp.status = context.responseStatus;
+ } catch (e) {
+ if (e instanceof Components.interfaces.nsIXPCException
+ && e.result == Components.results.NS_ERROR_NOT_AVAILABLE) {
+ // Reading context.responseStatus can fail in this way when
+ // there is no HTTP response; e.g., when the connection is
+ // reset.
+ }
+ }
if (Components.isSuccessCode(status)) {
resp.body = btoa(this.body.join(""));
} else {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits