Skip to content

Commit

Permalink
Added credits at the top.
Browse files Browse the repository at this point in the history
Fixed the history section links.
  • Loading branch information
unknown authored and unknown committed Jul 12, 2011
1 parent e5509f3 commit 56dcc52
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 19 deletions.
70 changes: 55 additions & 15 deletions simple-rest-client/improved_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ html, body {
margin-left: 0;
width: 100%;
height: 100%;
font-family: arial, helvetica;
font-family: Helvetica, Arial, sans-serif;
}

header {
Expand All @@ -17,6 +17,19 @@ header {
border-bottom-style: solid;
border-bottom-color: #116284;
border-bottom-width: 5px;
height: 70px;
width: 100%;
}

footer {
display: block;
font-size: 12px;
padding: 10px;
border-top-style: solid;
border-top-color: #116284;
border-top-width: 5px;
width: 100%;
height: 40px;
}

header h1 {
Expand Down Expand Up @@ -86,11 +99,10 @@ fieldset {
min-height: 100%;
width: 35%;
box-shadow: inset 4px 4px 10px #c5c5c5;
margin-right: 0px;
padding-top: 10px;
}

.headerText {
font-family: neue, SANS-SERIF;
font-weight: bolder;
font-size: 100%;
}
Expand Down Expand Up @@ -180,10 +192,11 @@ fieldset {

#logo {
padding: 20px;
float: left
}

#historyContainer {
padding-top: 20px;
padding-top: 10px;
padding-left: 10px;
}

Expand All @@ -206,9 +219,17 @@ fieldset {
margin-top: 20px;
}

#responseHeaders,
#responsedata,
#headers,
#body, #codeData {
font-family: "Consolas", Courier, monospace, sans-serif;
font-size: 12px;
}

#historyItems li {
margin-right: 7px;
padding: 5px;
padding: 8px;
border-radius: 5px;
}

Expand All @@ -219,13 +240,14 @@ fieldset {
#historyItems li a {
color: #333;
font-size: 12px;
margin-top: 2px;
text-decoration: none;
}

.itemDeleteLink {
float: right;
margin-right: 20px;
height: 12px;
margin-top: -2px;
display: none;
}

Expand All @@ -237,7 +259,6 @@ fieldset {
float: right;
font-size: 12px;
font-weight: bold;
margin-top: 2px;
margin-right: 30px;
display: none;
}
Expand Down Expand Up @@ -330,6 +351,32 @@ fieldset {
margin-left: 10px;
}


#credits {
float: right;
margin-right: 20px;
margin-top: 35px;
color: #fff;
font-weight: bold;
font-size: 10px;
}

#credits a {
background-color: #222;
color: #fff;
padding: 4px;
border-radius: 4px;
border: solid thin #222;
text-decoration: none;
font-weight: bold;
}

#credits a:hover {
background-color: #555;
border: solid thin #555;
text-decoration: none;
}

li .left {
float: left;
}
Expand All @@ -350,11 +397,4 @@ li .right {

* html .clearfix {
zoom: 1;
}

/* IE6 */
*:first-child+html .clearfix {
zoom: 1;
}

/* IE7 */
}
5 changes: 4 additions & 1 deletion simple-rest-client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
</head>
<body>
<header>
<div id="logo">
<div id="logo" class="clearfix">
<img src="images/postman.jpg" alt="POSTMAN"/>
<span class="smallheadertext"> An HTTP client to test web services</span>
</div>
<div id="notification">
<span>Loading</span><img src="images/loader.gif"/>
</div>
<div id="credits">
By <a href="http://twitter.com/a85" target="_blank">@a85</a> and <a href="http://twitter.com/slarti" target="_blank">@slarti</a>
</div>
</header>
<div id="main">
<section id="request">
Expand Down
11 changes: 8 additions & 3 deletions simple-rest-client/requester.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,16 +604,21 @@ function removeBodyListeners() {
$('#body').unbind("blur");
}

function setContainerHeights() {
$("#responseHeaders").width($("#main").width() - 80);
$("#responseData").width($("#main").width() - 80);
$('#history').css("height", $('#main').height());
}

$(document).ready(function() {
lang();
init();
getAllSavedRequests();
addHeaderListeners();
setContainerHeights();

$(window).resize(function() {
$("#responseHeaders").width($("#main").width() - 80);
$("#responseData").width($("#main").width() - 80);
$('#history').css("height", $('#main').height());
setContainerHeights();
});

});
Expand Down
109 changes: 109 additions & 0 deletions tools/httprequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php
/**
* Access the HTTP Request
*/
class http_request {

/** additional HTTP headers not prefixed with HTTP_ in $_SERVER superglobal */
var $add_headers = array('CONTENT_TYPE', 'CONTENT_LENGTH');

/**
* Construtor
* Retrieve HTTP Body
* @param Array Additional Headers to retrieve
*/
function http_request($add_headers = false) {

$this->retrieve_headers($add_headers);
$this->body = @file_get_contents('php://input');
}

/**
* Retrieve the HTTP request headers from the $_SERVER superglobal
* @param Array Additional Headers to retrieve
*/
function retrieve_headers($add_headers = false) {

if ($add_headers) {
$this->add_headers = array_merge($this->add_headers, $add_headers);
}

if (isset($_SERVER['HTTP_METHOD'])) {
$this->method = $_SERVER['HTTP_METHOD'];
unset($_SERVER['HTTP_METHOD']);
} else {
$this->method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : false;
}
$this->protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : false;
$this->request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : false;

$this->headers = array();
foreach($_SERVER as $i=>$val) {
if (strpos($i, 'HTTP_') === 0 || in_array($i, $this->add_headers)) {
$name = str_replace(array('HTTP_', '_'), array('', '-'), $i);
$this->headers[$name] = $val;
}
}
}

/**
* Retrieve HTTP Method
*/
function method() {
return $this->method;
}

/**
* Retrieve HTTP Body
*/
function body() {
return $this->body;
}

/**
* Retrieve an HTTP Header
* @param string Case-Insensitive HTTP Header Name (eg: "User-Agent")
*/
function header($name) {
$name = strtoupper($name);
return isset($this->headers[$name]) ? $this->headers[$name] : false;
}

/**
* Retrieve all HTTP Headers
* @return array HTTP Headers
*/
function headers() {
return $this->headers;
}

/**
* Return Raw HTTP Request (note: This is incomplete)
* @param bool ReBuild the Raw HTTP Request
*/
function raw($refresh = false) {

if (isset($this->raw) && !$refresh) {
return $this->raw; // return cached
}

$headers = $this->headers();
$this->raw = "{$this->method}\r\n";

foreach($headers as $i=>$header) {
$this->raw .= "$i: $header\r\n";
}

$this->raw .= "\r\n{$this->body}";

return $this->raw;
}
}

/**
*
* Echos the HTTP Request back the client/browser (in the HTTP Body)
*/
$http_request = new http_request();
$resp = $http_request->raw();
echo $resp;

0 comments on commit 56dcc52

Please sign in to comment.