зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1808309 - [devtools] Remove web console actor's sendHttpRequest method. r=devtools-reviewers,devtools-backward-compat-reviewers,nchevobbe
This is no longer used by the DevTools frontend. NetworkContent.sendHTTPRequest should be used instead. Differential Revision: https://phabricator.services.mozilla.com/D165865
This commit is contained in:
Родитель
4597b94bcd
Коммит
ee7ed1e669
|
@ -192,50 +192,6 @@ This notification is sent only when your client is attached to the global consol
|
|||
.. note::
|
||||
This notification has been introduced in Firefox 24.
|
||||
|
||||
|
||||
Send HTTP requests
|
||||
------------------
|
||||
|
||||
Starting with Firefox 25 you can send an HTTP request using the console actor:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
{
|
||||
"to": "conn0.console9",
|
||||
"type": "sendHTTPRequest",
|
||||
"request": {
|
||||
"url": "http://localhost",
|
||||
"method": "GET",
|
||||
"headers": [
|
||||
{
|
||||
name: "Header-name",
|
||||
value: "header value",
|
||||
},
|
||||
// ...
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
The response packet is a network event actor grip:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"to": "conn0.console9",
|
||||
"eventActor": {
|
||||
"actor": "conn0.netEvent14",
|
||||
"startedDateTime": "2013-08-26T19:50:03.699Z",
|
||||
"url": "http://localhost",
|
||||
"method": "GET"
|
||||
"isXHR": true,
|
||||
"private": false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
You can also use the ``webConsoleClient.sendHTTPRequest(request, onResponse)`` method. The ``request`` argument is the same as the ``request`` object in the above example request packet.
|
||||
|
||||
Page errors
|
||||
***********
|
||||
|
||||
|
@ -700,7 +656,6 @@ Protocol changes by Firefox version:
|
|||
- Firefox 24: new ``isXHR`` flag for the ``networkEvent`` notification, `bug <https://bugzilla.mozilla.org/show_bug.cgi?id=859046>`_.
|
||||
- Firefox 24: removed the ``message`` property from the ``pageError`` packet notification, `bug <https://bugzilla.mozilla.org/show_bug.cgi?id=877773>`_. The ``lineText`` and ``errorMessage`` properties can be long string actors now.
|
||||
- Firefox 25: added the ``url`` option to the ``evaluateJS`` request packet.
|
||||
- Firefox 25: added the ``getPreferences`` and ``sendHTTPRequest`` request packets to the console actor, `bug <https://bugzilla.mozilla.org/show_bug.cgi?id=886067>`_ and `bug <https://bugzilla.mozilla.org/show_bug.cgi?id=731311>`_.
|
||||
|
||||
|
||||
Conclusions
|
||||
|
|
|
@ -31,13 +31,6 @@ const DevToolsUtils = require("resource://devtools/shared/DevToolsUtils.js");
|
|||
const ErrorDocs = require("resource://devtools/server/actors/errordocs.js");
|
||||
const Targets = require("resource://devtools/server/actors/targets/index.js");
|
||||
|
||||
const lazy = {};
|
||||
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
NetworkUtils:
|
||||
"resource://devtools/shared/network-observer/NetworkUtils.sys.mjs",
|
||||
});
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"evalWithDebugger",
|
||||
|
@ -56,11 +49,6 @@ loader.lazyRequireGetter(
|
|||
"resource://devtools/shared/webconsole/js-property-provider.js",
|
||||
true
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
lazy,
|
||||
"NetUtil",
|
||||
"resource://gre/modules/NetUtil.jsm"
|
||||
);
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
["isCommand", "validCommands"],
|
||||
|
@ -1651,65 +1639,6 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
|||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Send a new HTTP request from the target's window.
|
||||
*
|
||||
* @param object request
|
||||
* The details of the HTTP request.
|
||||
*/
|
||||
async sendHTTPRequest(request) {
|
||||
const { url, method, headers, body, cause } = request;
|
||||
// Set the loadingNode and loadGroup to the target document - otherwise the
|
||||
// request won't show up in the opened netmonitor.
|
||||
const doc = this.global.document;
|
||||
|
||||
const channel = lazy.NetUtil.newChannel({
|
||||
uri: lazy.NetUtil.newURI(url),
|
||||
loadingNode: doc,
|
||||
securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
|
||||
contentPolicyType:
|
||||
lazy.NetworkUtils.stringToCauseType(cause.type) ||
|
||||
Ci.nsIContentPolicy.TYPE_OTHER,
|
||||
});
|
||||
|
||||
channel.QueryInterface(Ci.nsIHttpChannel);
|
||||
|
||||
channel.loadGroup = doc.documentLoadGroup;
|
||||
channel.loadFlags |=
|
||||
Ci.nsIRequest.LOAD_BYPASS_CACHE |
|
||||
Ci.nsIRequest.INHIBIT_CACHING |
|
||||
Ci.nsIRequest.LOAD_ANONYMOUS;
|
||||
|
||||
channel.requestMethod = method;
|
||||
if (headers) {
|
||||
for (const { name, value } of headers) {
|
||||
if (name.toLowerCase() == "referer") {
|
||||
// The referer header and referrerInfo object should always match. So
|
||||
// if we want to set the header from privileged context, we should set
|
||||
// referrerInfo. The referrer header will get set internally.
|
||||
channel.setNewReferrerInfo(
|
||||
value,
|
||||
Ci.nsIReferrerInfo.UNSAFE_URL,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
channel.setRequestHeader(name, value, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (body) {
|
||||
channel.QueryInterface(Ci.nsIUploadChannel2);
|
||||
const bodyStream = Cc[
|
||||
"@mozilla.org/io/string-input-stream;1"
|
||||
].createInstance(Ci.nsIStringInputStream);
|
||||
bodyStream.setData(body, body.length);
|
||||
channel.explicitSetUploadStream(bodyStream, null, -1, method, false);
|
||||
}
|
||||
|
||||
lazy.NetUtil.asyncFetch(channel, () => {});
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler for file activity. This method sends the file request information
|
||||
* to the remote Web Console client.
|
||||
|
|
|
@ -193,19 +193,6 @@ const webconsoleSpecPrototype = {
|
|||
clearMessagesCacheAsync: {
|
||||
request: {},
|
||||
},
|
||||
|
||||
/**
|
||||
* Send a HTTP request with the given data.
|
||||
*
|
||||
* @Arg object data
|
||||
* The details of the HTTP request.
|
||||
*/
|
||||
sendHTTPRequest: {
|
||||
request: {
|
||||
request: Arg(0, "json"),
|
||||
},
|
||||
response: RetVal("json"),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче