You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/07/05 21:44:55 UTC
[GitHub] jcesarmobile closed pull request #5: Add ignore-header feature
jcesarmobile closed pull request #5: Add ignore-header feature
URL: https://github.com/apache/cordova-weinre/pull/5
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/weinre.web/modules/weinre/target/HookSites.coffee b/weinre.web/modules/weinre/target/HookSites.coffee
index d3ac492..7d8c53a 100644
--- a/weinre.web/modules/weinre/target/HookSites.coffee
+++ b/weinre.web/modules/weinre/target/HookSites.coffee
@@ -32,6 +32,7 @@ HookSites.window_addEventListener = HookLib.addHookSite window, "addEven
HookSites.Node_addEventListener = HookLib.addHookSite Node.prototype, "addEventListener"
HookSites.XMLHttpRequest_open = HookLib.addHookSite XMLHttpRequest.prototype, "open"
HookSites.XMLHttpRequest_send = HookLib.addHookSite XMLHttpRequest.prototype, "send"
+HookSites.XMLHttpRequest_setRequestHeader = HookLib.addHookSite XMLHttpRequest.prototype, "setRequestHeader"
HookSites.XMLHttpRequest_addEventListener = HookLib.addHookSite XMLHttpRequest.prototype, "addEventListener"
if window.openDatabase
diff --git a/weinre.web/modules/weinre/target/NetworkRequest.coffee b/weinre.web/modules/weinre/target/NetworkRequest.coffee
index 8a33ad5..f6aaa59 100644
--- a/weinre.web/modules/weinre/target/NetworkRequest.coffee
+++ b/weinre.web/modules/weinre/target/NetworkRequest.coffee
@@ -98,6 +98,7 @@ module.exports = class NetworkRequest
stackTrace.push({functionName: frame})
xhr.__weinreNetworkRequest__ = new NetworkRequest(xhr, id, method, url, stackTrace)
+ xhr.__headers__ = xhr.__headers__ || {}
HookLib.ignoreHooks ->
xhr.addEventListener "readystatechange", getXhrEventHandler(xhr), false
@@ -110,9 +111,21 @@ module.exports = class NetworkRequest
data = args[0]
nr = xhr.__weinreNetworkRequest__
return unless nr
+ if xhr.__headers__["Weinre-Ignore"]
+ return
nr.handleSend(data)
+ #-----------------------------------------------------------------------
+ HookSites.XMLHttpRequest_setRequestHeader.addHooks
+
+ before: (receiver, args) ->
+ xhr = receiver
+ nr = xhr.__weinreNetworkRequest__
+ return unless nr
+
+ xhr.__headers__[args[0]] = args[1]
+
#-------------------------------------------------------------------------------
getRequest = (url, method, xhr, data) ->
@@ -190,6 +203,8 @@ getXhrEventHandler = (xhr) ->
->
nr = xhr.__weinreNetworkRequest__
return unless nr
+ if xhr.__headers__["Weinre-Ignore"]
+ return
try
switch xhr.readyState
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org