Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added little sinatra server to test the whole thing
- Loading branch information
Tobias Lütke
committed
May 24, 2009
1 parent
4e4ad9e
commit 661617b
Showing
8 changed files
with
73 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
def crc32 | ||
Zlib.crc32(@body, 0) | ||
def crc32(content) | ||
Zlib.crc32(content, 0) | ||
end | ||
|
||
def String | ||
def crc32 | ||
Kernel.crc32(self) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'rubygems' | ||
require 'sinatra' | ||
require 'memcached' | ||
|
||
$cache = Memcached.new('localhost:11211') | ||
|
||
|
||
# Set endpoint location for localhost address to be google.com | ||
$cache.set 'proxy/http://localhost:3005/proxy/test', 'http://www.example.com' | ||
|
||
|
||
get '/' do | ||
"<h1>Proxy Test</h1><p>Go to <a href='/proxy/test'>Test page</a>" | ||
end | ||
|
||
|
||
get '/proxy/test' do | ||
|
||
content_key = request.env['HTTP_X_PROXY_CONTENT'] ||'nothing' | ||
status = request.env['HTTP_X_PROXY_STATUS'] ||'nothing' | ||
|
||
content = $cache.get(content_key) | ||
|
||
"<h1>Proxy Test</h1><p>Proxy Status: #{status}</p><p>Proxy Key: #{content_key}</p><p>Proxy Content: #{content.length} bytes</p><blockquote style='padding:10px; border: 1px solid #ccc;'>#{content}</blockquote>" | ||
end |