Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 109 lines (83 sloc) 2.853 kb
3b9e4a1 @klacke new ret vals from out/1
authored
1
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
2 <erl>
3b9e4a1 @klacke new ret vals from out/1
authored
3
7811247 @vinoski whitespace cleanup
vinoski authored
4 out(A) ->
20ece13 @klacke more css hackery
authored
5 {ssi, "TAB.inc","%%",[{"redirect", "choosen"}]}.
3b9e4a1 @klacke new ret vals from out/1
authored
6
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
7 </erl>
3b9e4a1 @klacke new ret vals from out/1
authored
8
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
9 <div id="entry">
3b9e4a1 @klacke new ret vals from out/1
authored
10
e35a591 @klacke more w3c compliance
authored
11 <h2>Redirects</h2>
3b9e4a1 @klacke new ret vals from out/1
authored
12
7811247 @vinoski whitespace cleanup
vinoski authored
13 <p> Redirs are a powerful tool in the webapp programmer toolbox. The
14 Webserver returns a specific status code (302) and adds a
5ddf4f4 @klacke Bug fixed with bindings that got propagated over redirects. Good ol get/...
authored
15 "Location:" header
16 to the responce headers to the Browser. The Browser then displays the new
17 page as indicated in the "Location" header.</p>
3b9e4a1 @klacke new ret vals from out/1
authored
18
5ddf4f4 @klacke Bug fixed with bindings that got propagated over redirects. Good ol get/...
authored
19 <p> Yaws supports a number of different forms of redirect return values
20 from the out/1 function.</p>
21 <p>
22 The code:</p>
3b9e4a1 @klacke new ret vals from out/1
authored
23
24 <erl>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
25 out(_A) ->
0be3c7e @klacke untabified all of yaws
authored
26 {ehtml,
27 {'div', [{class,"box"}],
28 {pre,[],
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
29 {ssi, "redirect2.yaws",[],[]}}}}.
30 </erl>
31
32 <p> Clickable <a href="redirect2.yaws"> On this link </a> executes the
5ddf4f4 @klacke Bug fixed with bindings that got propagated over redirects. Good ol get/...
authored
33 above redirect code.
34 </p>
3b9e4a1 @klacke new ret vals from out/1
authored
35
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
36 <p> The code above redirects to an external URL. The HTTP RFC mandates
7811247 @vinoski whitespace cleanup
vinoski authored
37 that the Loction header must contain complete URLs, including the
38 the method, http, https etc. A very common case of redirection, is
e35a591 @klacke more w3c compliance
authored
39 a to redirect to another file on the same server. The code
40 in <a href="redirect3.yaws"> redirect3.yaws </a> shows an example of
41 a yaws redirect relative to the "current" server.
42 </p>
3b9e4a1 @klacke new ret vals from out/1
authored
43
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
44 <erl>
45 out(_A) ->
0be3c7e @klacke untabified all of yaws
authored
46 {ehtml,
47 {'div', [{class,"box"}],
48 {pre,[],
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
49 {ssi, "redirect3.yaws",[],[]}}}}.
3b9e4a1 @klacke new ret vals from out/1
authored
50 </erl>
51
52
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
53 <p> The code in <a href="redirect3.yaws"> redirect3.yaws </a> will
7811247 @vinoski whitespace cleanup
vinoski authored
54 do a relative redirect to the code in
55 <a href="redirect2.yaws"> redirect2.yaws </a> which in its turn
e35a591 @klacke more w3c compliance
authored
56 redirects, once again, to google. Double redirects.
57 </p>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
58
7811247 @vinoski whitespace cleanup
vinoski authored
59 <p>While working with redirects, the tool <a href="http://curl.haxx.se/"> curl </a>
60 is an excellent way to troubleshoot the behaviour of your
e45a6e7 @klacke spelling fixes by ejonesca
authored
61 redirects. For example:</p>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
62
63 <div class="box">
5ddf4f4 @klacke Bug fixed with bindings that got propagated over redirects. Good ol get/...
authored
64 <verbatim>
65
66 # curl -I http://rubin.hyber.org:8000/redirect3.yaws
67
68 HTTP/1.1 302 Found
69 Server: Yaws/1.49 Yet Another Web Server
70 Location: http://rubin.hyber.org:8000/redirect2.yaws
71 Date: Tue, 16 Nov 2004 20:16:01 GMT
72 Content-Type: text/html
73
74 </verbatim>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
75 </div>
76
e35a591 @klacke more w3c compliance
authored
77 <p>Where <tt> http://rubin.hyber.org:8000</tt> is where I am currently
78 testing the <a href="redirect3.yaws"> redirect3.yaws </a> code.
79 Learn and use the <a href="http://curl.haxx.se/"> curl </a>
80 web client, it may not render pictures pretty, but it sure displays
81 headers.
82 </p>
83 <br />
84
85 <p> We show one additional version of redirect code. The code in
86 <a href="redirect3.yaws"> redirect3.yaws </a> requires an absolute path.
7811247 @vinoski whitespace cleanup
vinoski authored
87 If we want to supply a path relative to the current url, we can use
e35a591 @klacke more w3c compliance
authored
88 either the Redirect modifier <tt>rel_path</tt> or <tt>any_path</tt>
89 as in :
90 </p>
379666b @klacke documented jockes new bindings feature
authored
91
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
92 <erl>
93 out(_A) ->
0be3c7e @klacke untabified all of yaws
authored
94 {ehtml,
95 {'div', [{class,"box"}],
96 {pre,[],
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
97 {ssi, "redirect4.yaws",[],[]}}}}.
98 </erl>
99
100 <p> <a href = "redirect4.yaws"> Clickable here </a>
e35a591 @klacke more w3c compliance
authored
101 </p>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
102
103 </div>
104
105
106 <erl>
107 out(A) -> {ssi, "END2",[],[]}.
108 </erl>
Something went wrong with that request. Please try again.