diff options
Diffstat (limited to 'doc/url.html')
| -rw-r--r-- | doc/url.html | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/doc/url.html b/doc/url.html index f3a7cb7..cd699a2 100644 --- a/doc/url.html +++ b/doc/url.html | |||
| @@ -59,7 +59,7 @@ An URL is defined by the following grammar: | |||
| 59 | <!-- absolute +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 59 | <!-- absolute +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 60 | 60 | ||
| 61 | <p class=name id=absolute> | 61 | <p class=name id=absolute> |
| 62 | socket.url.<b>absolute(</b>base, relative<b>)</b> | 62 | url.<b>absolute(</b>base, relative<b>)</b> |
| 63 | </p> | 63 | </p> |
| 64 | 64 | ||
| 65 | <p class=description> | 65 | <p class=description> |
| @@ -79,7 +79,7 @@ The function returns a string with the absolute URL. | |||
| 79 | Note: The rules that | 79 | Note: The rules that |
| 80 | govern the composition are fairly complex, and are described in detail in | 80 | govern the composition are fairly complex, and are described in detail in |
| 81 | <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2396.txt">RFC 2396</a>. | 81 | <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2396.txt">RFC 2396</a>. |
| 82 | The example bellow should give an idea of what are the rules. | 82 | The example bellow should give an idea of what the rules are. |
| 83 | </p> | 83 | </p> |
| 84 | 84 | ||
| 85 | <pre class=example> | 85 | <pre class=example> |
| @@ -114,7 +114,7 @@ g;x?y#s = http://a/b/c/g;x?y#s | |||
| 114 | <!-- build ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 114 | <!-- build ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 115 | 115 | ||
| 116 | <p class=name id=build> | 116 | <p class=name id=build> |
| 117 | socket.url.<b>build(</b>parsed_url<b>)</b> | 117 | url.<b>build(</b>parsed_url<b>)</b> |
| 118 | </p> | 118 | </p> |
| 119 | 119 | ||
| 120 | <p class=description> | 120 | <p class=description> |
| @@ -135,7 +135,7 @@ The function returns a string with the built URL. | |||
| 135 | <!-- build_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 135 | <!-- build_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 136 | 136 | ||
| 137 | <p class=name id=build_path> | 137 | <p class=name id=build_path> |
| 138 | socket.url.<b>build_path(</b>segments, unsafe<b>)</b> | 138 | url.<b>build_path(</b>segments, unsafe<b>)</b> |
| 139 | </p> | 139 | </p> |
| 140 | 140 | ||
| 141 | <p class=description> | 141 | <p class=description> |
| @@ -157,10 +157,39 @@ The function returns a string with the | |||
| 157 | built <tt><path></tt> component. | 157 | built <tt><path></tt> component. |
| 158 | </p> | 158 | </p> |
| 159 | 159 | ||
| 160 | <!-- escape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 161 | |||
| 162 | <p class=name id="escape"> | ||
| 163 | url.<b>escape(</b>content<b>)</b> | ||
| 164 | </p> | ||
| 165 | |||
| 166 | <p class=description> | ||
| 167 | Applies the URL escaping content coding to a string | ||
| 168 | Each byte is encoded as a percent character followed | ||
| 169 | by the two byte hexadecimal representation of its integer | ||
| 170 | value. | ||
| 171 | </p> | ||
| 172 | |||
| 173 | <p class=parameters> | ||
| 174 | <tt>Content</tt> is the string to be encoded. | ||
| 175 | </p> | ||
| 176 | |||
| 177 | <p class=result> | ||
| 178 | The function returns the encoded string. | ||
| 179 | </p> | ||
| 180 | |||
| 181 | <pre class=example> | ||
| 182 | -- load url module | ||
| 183 | url = require("url") | ||
| 184 | |||
| 185 | code = url.escape("/#?;") | ||
| 186 | -- code = "%2f%23%3f%3b" | ||
| 187 | </pre> | ||
| 188 | |||
| 160 | <!-- parse ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 189 | <!-- parse ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 161 | 190 | ||
| 162 | <p class=name id=parse> | 191 | <p class=name id=parse> |
| 163 | socket.url.<b>parse(</b>url, default<b>)</b> | 192 | url.<b>parse(</b>url, default<b>)</b> |
| 164 | </p> | 193 | </p> |
| 165 | 194 | ||
| 166 | <p class=description> | 195 | <p class=description> |
| @@ -196,7 +225,10 @@ parsed_url = {<br> | |||
| 196 | </tt></blockquote> | 225 | </tt></blockquote> |
| 197 | 226 | ||
| 198 | <pre class=example> | 227 | <pre class=example> |
| 199 | parsed_url = socket.url.parse("http://www.puc-rio.br/~diego/index.lua?a=2#there") | 228 | -- load url module |
| 229 | url = require("url") | ||
| 230 | |||
| 231 | parsed_url = url.parse("http://www.puc-rio.br/~diego/index.lua?a=2#there") | ||
| 200 | -- parsed_url = { | 232 | -- parsed_url = { |
| 201 | -- scheme = "http", | 233 | -- scheme = "http", |
| 202 | -- authority = "www.puc-rio.br", | 234 | -- authority = "www.puc-rio.br", |
| @@ -206,7 +238,7 @@ parsed_url = socket.url.parse("http://www.puc-rio.br/~diego/index.lua?a=2#there" | |||
| 206 | -- host = "www.puc-rio.br", | 238 | -- host = "www.puc-rio.br", |
| 207 | -- } | 239 | -- } |
| 208 | 240 | ||
| 209 | parsed_url = socket.url.parse("ftp://root:passwd@unsafe.org/pub/virus.exe;type=i") | 241 | parsed_url = url.parse("ftp://root:passwd@unsafe.org/pub/virus.exe;type=i") |
| 210 | -- parsed_url = { | 242 | -- parsed_url = { |
| 211 | -- scheme = "ftp", | 243 | -- scheme = "ftp", |
| 212 | -- authority = "root:passwd@unsafe.org", | 244 | -- authority = "root:passwd@unsafe.org", |
| @@ -222,7 +254,7 @@ parsed_url = socket.url.parse("ftp://root:passwd@unsafe.org/pub/virus.exe;type=i | |||
| 222 | <!-- parse_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 254 | <!-- parse_path +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 223 | 255 | ||
| 224 | <p class=name id=parse_path> | 256 | <p class=name id=parse_path> |
| 225 | socket.url.<b>parse_path(</b>path<b>)</b> | 257 | url.<b>parse_path(</b>path<b>)</b> |
| 226 | </p> | 258 | </p> |
| 227 | 259 | ||
| 228 | <p class=description> | 260 | <p class=description> |
| @@ -241,36 +273,10 @@ returning a list with all the parsed segments, the function unescapes all | |||
| 241 | of them. | 273 | of them. |
| 242 | </p> | 274 | </p> |
| 243 | 275 | ||
| 244 | <!-- escape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 245 | |||
| 246 | <p class=name id="escape"> | ||
| 247 | socket.url.<b>escape(</b>content<b>)</b> | ||
| 248 | </p> | ||
| 249 | |||
| 250 | <p class=description> | ||
| 251 | Applies the URL escaping content coding to a string | ||
| 252 | Each byte is encoded as a percent character followed | ||
| 253 | by the two byte hexadecimal representation of its integer | ||
| 254 | value. | ||
| 255 | </p> | ||
| 256 | |||
| 257 | <p class=parameters> | ||
| 258 | <tt>Content</tt> is the string to be encoded. | ||
| 259 | </p> | ||
| 260 | |||
| 261 | <p class=result> | ||
| 262 | The function returns the encoded string. | ||
| 263 | </p> | ||
| 264 | |||
| 265 | <pre class=example> | ||
| 266 | code = socket.url.escape("/#?;") | ||
| 267 | -- code = "%2f%23%3f%3b" | ||
| 268 | </pre> | ||
| 269 | |||
| 270 | <!-- unescape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 276 | <!-- unescape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 271 | 277 | ||
| 272 | <p class=name id="unescape"> | 278 | <p class=name id="unescape"> |
| 273 | socket.url.<b>unescape(</b>content<b>)</b> | 279 | url.<b>unescape(</b>content<b>)</b> |
| 274 | </p> | 280 | </p> |
| 275 | 281 | ||
| 276 | <p class=description> | 282 | <p class=description> |
