mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1323454 - integrate HTTP Status code with MDN; r=Honza
MozReview-Commit-ID: 8DaFUZhEobr --HG-- extra : rebase_source : 90c6d823cbe1fae4ba0e73b96760070783afd7c0
This commit is contained in:
parent
0fa1b47441
commit
da577361e9
@ -12,7 +12,10 @@ const {
|
||||
} = require("devtools/client/shared/vendor/react");
|
||||
const { L10N } = require("../../utils/l10n");
|
||||
const { writeHeaderText } = require("../../utils/request-utils");
|
||||
const { getHeadersURL } = require("../../utils/mdn-utils");
|
||||
const {
|
||||
getHeadersURL,
|
||||
getHTTPStatusCodeURL,
|
||||
} = require("../../utils/mdn-utils");
|
||||
const { getFormattedSize } = require("../../utils/format-utils");
|
||||
const { REPS, MODE } = require("devtools/client/shared/components/reps/reps");
|
||||
const Rep = createFactory(REPS.Rep);
|
||||
@ -172,6 +175,9 @@ const HeadersPanel = createClass({
|
||||
code = status;
|
||||
}
|
||||
|
||||
let statusCodeDocURL = getHTTPStatusCodeURL(code);
|
||||
let inputWidth = status.length + statusText.length + 1;
|
||||
|
||||
summaryStatus = (
|
||||
div({ className: "tabpanel-summary-container headers-summary" },
|
||||
div({
|
||||
@ -182,10 +188,15 @@ const HeadersPanel = createClass({
|
||||
"data-code": code,
|
||||
}),
|
||||
input({
|
||||
className: "tabpanel-summary-value textbox-input devtools-monospace",
|
||||
className: "tabpanel-summary-value textbox-input devtools-monospace"
|
||||
+ " status-text",
|
||||
readOnly: true,
|
||||
value: `${status} ${statusText}`,
|
||||
size: `${inputWidth}`,
|
||||
}),
|
||||
statusCodeDocURL ? MDNLink({
|
||||
url: statusCodeDocURL,
|
||||
}) : null,
|
||||
window.NetMonitorController.supportsCustomRequest && button({
|
||||
className: "devtools-button",
|
||||
onClick: cloneSelectedRequest,
|
||||
|
@ -75,6 +75,34 @@ const SUPPORTED_HEADERS = [
|
||||
"X-XSS-Protection"
|
||||
];
|
||||
|
||||
/**
|
||||
* A mapping of HTTP status codes to external documentation. Any code included
|
||||
* here will show a MDN link alongside it.
|
||||
*/
|
||||
const SUPPORTED_HTTP_CODES = [
|
||||
"100",
|
||||
"200",
|
||||
"201",
|
||||
"204",
|
||||
"206",
|
||||
"301",
|
||||
"302",
|
||||
"303",
|
||||
"304",
|
||||
"307",
|
||||
"308",
|
||||
"404",
|
||||
"406",
|
||||
"410",
|
||||
"412",
|
||||
"451",
|
||||
"500",
|
||||
"501",
|
||||
"502",
|
||||
"503",
|
||||
"504"
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the MDN URL for the specified header.
|
||||
*
|
||||
@ -90,6 +118,19 @@ function getHeadersURL(header) {
|
||||
`https://developer.mozilla.org/docs/Web/HTTP/Headers/${SUPPORTED_HEADERS[idx]}?utm_source=mozilla&utm_medium=devtools-netmonitor&utm_campaign=default` : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MDN URL for the specified HTTP status code.
|
||||
*
|
||||
* @param {string} HTTP status code for the baseURL to use.
|
||||
*
|
||||
* @return {string} The MDN URL for the HTTP status code, or null if not available.
|
||||
*/
|
||||
function getHTTPStatusCodeURL(statusCode) {
|
||||
let idx = SUPPORTED_HTTP_CODES.indexOf(statusCode);
|
||||
return idx > -1 ? `https://developer.mozilla.org/docs/Web/HTTP/Status/${SUPPORTED_HTTP_CODES[idx]}` : null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getHeadersURL,
|
||||
getHTTPStatusCodeURL,
|
||||
};
|
||||
|
@ -670,6 +670,22 @@
|
||||
background: var(--theme-toolbar-background);
|
||||
}
|
||||
|
||||
.headers-summary .status-text {
|
||||
width: auto!important;
|
||||
}
|
||||
|
||||
.headers-summary .learn-more-link {
|
||||
color: var(--theme-highlight-blue);
|
||||
cursor: pointer;
|
||||
margin: 0 5px;
|
||||
white-space: nowrap;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.headers-summary .learn-more-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* Response tabpanel */
|
||||
|
||||
.response-error-header {
|
||||
|
Loading…
Reference in New Issue
Block a user