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