Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
169 lines (153 sloc) 5.87 KB
<html>
<head>
<title>Foobar3000 - the world's most advanced test server</title>
<link rel='stylesheet' href='assets/style.min.css' type='text/css' />
<link rel='alternate stylesheet' href='assets/style.css' type='text/css' />
<script src="assets/ender.js"></script>
</head>
<body>
<div id="top">
<h1 id='header'>Foobar3000</h1>
<h1 id='tagline'>The world's most advanced echo server!</h1>
</div>
<a href="http://github.com/coolaj86/foobar3000"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/abad93f42020b733148435e2cd92ce15c542d320/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub"></a>
<div id="http" class="section">
<h2 class='section_head'>Wow... just wow.</h2>
<ul>
<li>HTTP Echo on ports 80, 8080</li>
<li>TCP Echo on port 32000</li>
<li>UDP Echo on port 32000</li>
</ul>
<p>
<a href="http://helloworld3000.com">helloworld3000.com</a> - An alias of foobar3000.com suitable for testing CORS, XSS, etc.
</p>
<p>
<h3 class='section_head'>What's your IP?</h2> <a href="http://checkip.foobar3000.com">checkip.foobar3000.com</a> - no muss, no fuss, no markup, no `sed`, `awk`, or `.trim()` needed.
</p>
</div>
<div id="http" class="section">
<h2 class='section_head'>HTTP Echo</h2>
<ul>
<li>`GET /` with no parameters returns this page</li>
<li>`[VERB] /echo?foo=bar` will echo the parameters you have given</li>
<li>`GET /echo?headers=X-Test-Header%3A%20Hello%2FWorld` replies to the request with the additional header `X-Test-Header: Hello World`</li>
<li>`GET /echo?body=Hello%20World%0A` replies to the request with the body `Hello World\n`</li>
<li>`POST /meta?session=same-token&pathname=%2Ffoobar&body=Hello%20Foo%0A` creates the resource `/foobar` for the session `same-token` with whatever headers and body specified</li>
<li>`GET /foobar?session=same-token` response with the resource just created (or an echo if there was none)</li>
<li>`GET /checkip` returns your IP Address as `text/plain`, no html, no spaces, no need to `.trim()`</li>
<li>Any sessions created will be deleted after 10 minutes of inactivity</li>
</ul>
For your prototyping pleasure, Ender.JS is loaded on this page with the following modules:
<ul>
<li>jeesh</li>
<li>reqwest</li>
<li>jQuery</li>
<li>ahr2</li>
</ul>
<h3 class='section_head'>Open up your console and play away:</h3>
<pre>
<code class="javascript">
var jQuery = require('jQuery') // jQuery 1.6.3
, $ = require('ender') // same DOM API as jQuery
, ajax = require('reqwest') // same API as jQuery.ajax
, request = require('ahr2') // similar API to Node.JS' `request`, supports XHR2
;
request('/echo').when(function (err, ahr, data) {
console.log(arguments);
});
// Use foobar3000.com to create a CORS resource
// (attached to session)
function createCorsResource() {
request.post('/meta', null, {
session: "make-up-your-own-key"
, pathname: "/hello-cors"
, headers: [
"Access-Control-Allow-Origin: *"
, "Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS"
, "Access-Control-Allow-Headers: Content-Type, Accept"
]
, body: "Hello CORS World!"
}, { headers: { "content-type": "application/json"} }).when(function (err, ahr, data) {
console.log(arguments);
getCorsResource();
});
}
// Access the aforementioned resource from helloworld3000.com
// (must use same session key)
function getCorsResource() {
request.get('http://helloworld3000.com/hello-cors?session=make-up-your-own-key').when(function (err, ahr, data) {
console.log(arguments);
});
}
createCorsResource();
</code>
</pre>
<h3 class='section_head'>Or play from another browser page:</h3>
<pre>
<code class="javascript">
var script = document.createElement('script');
script.src = 'http://foobar3000.com/assets/ender.js';
script = document.body.appendChild(script);
</code>
</pre>
</div>
<div id="tcp" class="section">
<h2 class='section_head'>TCP Echo</h2>
<h3 class='section_head'>Persistent connection:</h3>
<pre><code>
nc -l -p 5000 # GNU netcat
# nc -l 5000 # BSD netcat
nc foobar3000.com 32000
Hey you!
{ "keepalive": true }
{ "keepalive": false }
{ "body": "Hello\n" }
{ "body": "Hello\n" }
{ "body": "Hello\n" NOT JSON }
{ "body": "Hello\n", "port": 5000 }
{ "port": 5000 }
{ "body": "Hello\n", "port": 5000 }
</code></pre>
<ul>
<li>
keepalive - wether or not to send extra `ACK`s to verify connection
</li>
<li>
body - the message to send back
</li>
<li>
port - the port to connect back to (will connect from a different port)
</li>
</ul>
</div>
<div id="udp" class="section">
<h2 class='section_head'>UDP Echo</h2>
<h3 class='section_head'>Persistent (responds from bound listener):</h3>
<pre><code>
nc -u -l -p 5000 # BSD netcat
nc -u foobar3000.com 32000
Hey you!
{ "body": "Hello\n" }
{ "body": "Hello\n" NOT JSON }
{ "port": 5000 }
{ "body": "Hello\n", "redial": true }
{ "body": "Hello\n", "port": 5000 }
{ "body": "Hello\n", "redial": true, "port": 5000 }
</code></pre>
<ul>
<li>
body - the message to send back
</li>
<li>
port - the port to send back to (will be the same unless `redial` is requested
</li>
<li>
redial - whether to use the bound port or a random port to respond
</li>
</ul>
</div>
<div id="footer">
For all your echoing needs!
</div>
</body>
</html>