Skip to content

Commit

Permalink
Signed-off
Browse files Browse the repository at this point in the history
  • Loading branch information
phempshall committed Nov 29, 2016
0 parents commit d07376e
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 0 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---------------------------------------------------------------------

HTTP Headers - https://www.paulhempshall.com/io/http-headers/
Copyright (C) 2016, Paul Hempshall. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

---------------------------------------------------------------------
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# HTTP Headers ![Supported](https://img.shields.io/badge/browser-chrome-green.svg "Supported Platforms") [![Bitcoin](https://img.shields.io/badge/donations-Bitcoin-orange.svg)](https://blockchain.info/address/1K1AhrU5JS8euypB3Vw2iGxXqsbwcf9kxN)

A web browser extension that displays the current page's HTTP request and response.

Currently available for Chrome

## Installation

Not available from the store.

Download the latest package for your browser from the [releases](https://github.com/phempshall/http-headers/releases) page.



## License

HTTP Headers
Copyright (C) 2016, Paul Hempshall. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

https://opensource.org/licenses/GPL-3.0
9 changes: 9 additions & 0 deletions chrome/fetchHeaders.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>HTTP Headers</title>
</head>
<body>
<script src="fetchHeaders.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions chrome/fetchHeaders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

var headers = {};

var filters = {
urls: ["<all_urls>"],
types: ["main_frame"]
};

/* headers received */
chrome.webRequest.onHeadersReceived.addListener(function(details) {
headers[details.tabId] = headers[details.tabId] || {};
headers[details.tabId].response = details;
}, filters, ["responseHeaders"]);

/* headers sent */
chrome.webRequest.onSendHeaders.addListener(function(details) {
headers[details.tabId] = headers[details.tabId] || {};
headers[details.tabId].request = details;
}, filters, ["requestHeaders"]);
49 changes: 49 additions & 0 deletions chrome/headersPopup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<title>HTTP Headers</title>
<script src="headersPopup.js"></script>
<style>
body {
min-width: 420px;
max-height: 740px;
overflow-y: auto;
color: #383838;
}
p {
word-break: break-all;
margin: 0;
background: #fcfcfc;
padding: .25em .15em;
border: 1px solid #e8e8e8;
border-top: 0;
}
.error-text {
font-weight: 700;
color: #c03;
border-top: 1px solid #e8e8e8;
}
h1{
border-bottom: 1px solid #f9f9f9;
margin: 0 0 .5em;
}
h2 {
margin: 1.25em 0 0 0;
padding: 0 0 .75em 0;
font-size: 1.4em;
line-height: 1em;
border-bottom: 1px solid #e8e8e8;
}
</style>
</head>
<body>

<h1>
HTTP Headers
</h1>

<div id="results"></div>


</body>
</html>
57 changes: 57 additions & 0 deletions chrome/headersPopup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict';

chrome.tabs.query({active: true, currentWindow: true}, function(tab) {
var results = document.getElementById('results'),
headers = chrome.extension.getBackgroundPage().headers[tab[0].id];

function printError () {
var error = {
container: document.createElement('p'),
text: document.createTextNode("Error: could not get http headers, please try refreshing the page.")
}
error.container.className = "error-text";
error.container.appendChild(error.text)
results.appendChild(error.container);
}

function printResults () {
Object.keys(headers).forEach(function(key) {
console.log(headers[key]);
headers[key][key + 'Headers'].sort(function(a,b) {return (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0);});

printHeading(key);

for (var i = 0; i < headers[key][key + 'Headers'].length; i++) {
printHeader(headers[key][key + 'Headers'][i]);
}
});

function printHeading (key) {
var n = key[0].toUpperCase() + key.substring(1);
var h = document.createElement('h2'),
t = document.createTextNode(n);
h.appendChild(t);
results.appendChild(h);
}

function printHeader (obj) {
var p = document.createElement('p'),
b = document.createElement('b'),
t_name = document.createTextNode(obj.name + ': '),
t_value = document.createTextNode(obj.value);
b.appendChild(t_name);

p.appendChild(b);
p.appendChild(t_value);
results.appendChild(p);
}
}


if (headers === undefined) {
printError();
}
else {
printResults();
}
});
Binary file added chrome/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/icon-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/icon-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/icon-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/icon-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/icon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"manifest_version": 2,
"author": "Paul Hempshall",

"name": "HTTP Headers",
"version": "1.0.0",
"description": "This extension will show you the current HTTP headers",

"background": {
"page": "fetchHeaders.html"
},

"browser_action": {
"default_title": "HTTP Headers",
"default_popup": "headersPopup.html"
},

"icons": {
"16": "icon-16.png",
"32": "icon-32.png",
"48": "icon-48.png",
"64": "icon-64.png",
"128": "icon-128.png",
"256": "icon-256.png"
},

"permissions": [
"webRequest",
"webRequestBlocking",
"tabs",
"*://*/*"
]
}

0 comments on commit d07376e

Please sign in to comment.