Created
January 24, 2014 08:32
-
-
Save mubix/8593954 to your computer and use it in GitHub Desktop.
Attempting to use a 305 HTTP code
This file contains hidden or 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
require 'sinatra' | |
# Notes: | |
# https://www.youtube.com/watch?v=H9Kxas65f7A @ 5 minutes 20 seconds | |
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.6 | |
# http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#305_Proxy | |
# http://www.checkupdown.com/status/E305.html | |
get '/' do | |
status 305 | |
headers['Location'] = 'http://127.0.0.1:8080' | |
<<-eos | |
<html> | |
<head> | |
<title>305 Use Proxy</title> | |
</head> | |
<body> | |
<h1>Use Proxy</h1> | |
<p>This resource is only accessible through the proxy http://127.0.0.1:8080/<br />You will need to configure your client to use that proxy.</p> | |
</body> | |
</html> | |
eos | |
end | |
=begin | |
==== webrick output ======== | |
[2014-01-24 03:28:26] INFO WEBrick 1.3.1 | |
[2014-01-24 03:28:26] INFO ruby 1.9.3 (2013-11-22) [x86_64-darwin13.0.0] | |
== Sinatra/1.4.2 has taken the stage on 4567 for development with backup from WEBrick | |
[2014-01-24 03:28:26] INFO WEBrick::HTTPServer#start: pid=4243 port=4567 | |
127.0.0.1 - - [24/Jan/2014 03:28:29] "GET / HTTP/1.1" 305 249 0.0030 | |
localhost - - [24/Jan/2014:03:28:29 EST] "GET / HTTP/1.1" 305 249 | |
- -> / | |
==== curl output ========== | |
~ $ curl -v http://127.0.0.1:4567 | |
* About to connect() to 127.0.0.1 port 4567 (#0) | |
* Trying 127.0.0.1... | |
* Adding handle: conn: 0x7f8998804000 | |
* Adding handle: send: 0 | |
* Adding handle: recv: 0 | |
* Curl_addHandleToPipeline: length: 1 | |
* - Conn 0 (0x7f8998804000) send_pipe: 1, recv_pipe: 0 | |
* Connected to 127.0.0.1 (127.0.0.1) port 4567 (#0) | |
> GET / HTTP/1.1 | |
> User-Agent: curl/7.30.0 | |
> Host: 127.0.0.1:4567 | |
> Accept: */* | |
> | |
< HTTP/1.1 305 Use Proxy | |
< Content-Type: text/html;charset=utf-8 | |
< Location: http://127.0.0.1:8080 | |
< Content-Length: 249 | |
< X-Xss-Protection: 1; mode=block | |
< X-Content-Type-Options: nosniff | |
< X-Frame-Options: SAMEORIGIN | |
* Server WEBrick/1.3.1 (Ruby/1.9.3/2013-11-22) is not blacklisted | |
< Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-11-22) | |
< Date: Fri, 24 Jan 2014 08:28:29 GMT | |
< Connection: Keep-Alive | |
< | |
<html> | |
<head> | |
<title>305 Use Proxy</title> | |
</head> | |
<body> | |
<h1>Use Proxy</h1> | |
<p>This resource is only accessible through the proxy http://127.0.0.1:8080/<br />You will need to configure your client to use that proxy.</p> | |
</body> | |
</html> | |
* Connection #0 to host 127.0.0.1 left intact | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment