2010-10-06 15 views
3

如何在使用HTTP观察者时将传入响应映射到传出请求:https://developer.mozilla.org/en/Setting_HTTP_request_headers#Observers如何在使用“http-on-modify-request”和“http-on-examine-response”时映射对请求的响应?

+1

只是存储在阵列中的请求,因为他们走出去,然后用的indexOf找出哪个是哪个?我想这就是HttpFox所做的。 – MatrixFrog 2010-10-06 15:52:20

+0

调查HttpFox源代码:http://code.google.com/p/httpfox/source/browse/trunk/components/HttpFoxService.js感谢您指出! – spektom 2010-10-06 16:20:15

回答

1

比较nsIHttpChannel对象,如HttpFox作用:

getPendingRequestForRequestEvent: function(request) { 
    // check for matching request 
    for (var i = 0; i < this.Requests.length; i++) { 
     if (request.HttpChannel === this.Requests[i].HttpChannel) { 
     return i; 
     } 
    } 

    // no match found 
    return -1; 
},