Appendix 1. Paths to files and directories, working with HTTP-servers

To access files and directories in Parser, one may use absolute or relative paths.

Absolute path is started with slash. In this case, the file is searched for from web-space root. If a relative path is used, the file will be searched for from directory where requested document is located.

Example of absolute path:
/news/archive/20020127/sport.html

Example of relative path:
relative to directory
/news/archive
20020127/sport.html

While a file is saved, needed directories are created automatically.

Note: the root of web-space, passed by web-server, can be cahnged: see "Root of web-space"

Note: Parser transforms paths to
file-spec (see "External and internal data").


Methods…
·file::load  
·table::load  

…can work with external HTTP-servers, provided the name of document to be loaded starts with prefix
http://
If required, domain name is automaticaly encodes into IDNA representation. [3.4.4]

While using these methods, one can also specify extra options to control download behavior. These options are hash, with such keys as:


Option
Default
Value
$.charset[charset]
correspondes $request:charset
Charset used in documents on remote server. This charset is used to transcode request string. This charset is used to transcode response body if HTTP response does not contains charset.

This option also allowed while loading local text files. [3.2.2]

If a text file which is loaded without charset option, contains BOM code it will be transcoded automatically from UTF-8 to $request:charset.
[3.4.1]
$.response-charset[charset]
taken from HTTP response header
Force specify charset for response body. [3.4.4]
$.timeout(seconds)
2 seconds
HTTP server's response timeout in seconds. If download operation is not finished within this period, exception will be thrown.
$.method[HTTP-METHOD]
GET
The name of HTTP-method should be specified in uppercase only.

It's possible to specify it in lowercase as well. [3.3.1]
$.enctype[CONTENT-TYPE]
application/x-www-form-urlencoded
Possible values are:
application/x-www-form-urlencoded
or multipart/form-data.
Last one with method POST should be used if you need to send files to external HTTP server. [3.3.1]
$.form[
  
$.field[string]
  
$.field[
file]
  
$.field[
$table]
  …

]

none
Request parameters. For GET-request they will be passed in?query_string. For requests with other method, parameters will be passed with
Content-type: application/x-www-form-urlencoded
Parameter value can be string, table with one column or file [3.3.1].

It is preferable to pass parameters by means of
$.forms, and not pass it in?parameters by hand.

It is allowed to pass parameters in both styles simultaneously
. [3.1.5]
$.body[string]
none
Text body of the query. (do not use form or METHOD[GET] when you use body)
$.cookies[
  
$.name[value]
  …

]

none
Hash with list of cookies to be passed to HTTP-server. [3.2.3]
$.headers[
  $.HTTP-HEADER[value]
  
]

$.User-Agent[parser3]
Hash with additional HTTP-headers to be passed to HTTP-server

HTTP-header's value may be a date, string or hash with obligatory key value.
Date may be used as either field value or field's attribute value. In this case, it will be object to standard formatting.

$.any-status(true)
false/0
Boolean: is response status not equal to 200 allowed? If Boolean is FALSE, and received status is not equal to 200, system exception http.status will be thrown.
$.omit-post-charset(true)
false/0
Don't add charset info to HTTP-header content-type for outgoing POST request. [3.3.0]
$.response-charset[charset]
none
Force server output to specified charset. [3.4.3]
$.user[user]
none
These are request parameters to server,
$.password[password]
none
which uses standard HTTP-authorization.


For ^file::load[…] one can also specify additional loading options. These options are hash with such keys as:

Option
Default
Value
$.offset(offset)
0
While loading data, offset is specified in number of bytes.
$.limit(limit)
-1
Load no more than specified number of bytes



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 23.04.2016