1
.he ''--- URL processing ---''
5
Functions and modules to specify & convert URIs (URLs are a type of URI)
10
\fB$url=new URI::URL($url_str[,$base_url])\fP
12
Creates URI object. $url_str can be relative path & $base_url base path,
13
for example $url_str = "news" and $base_url = "http://3dnews.ru".
15
\fBabs([$base_url,[scheme])\fP Return converted relative path to absolute
16
(if $url_str in constructor given as relative path, otherwise returns $url_str
17
himself). If first parametr specified it used instead of value specified
18
in $base_url in constructor. If second parametr non-zero will accept relative
19
url with scheme but without host (http:index.html).
21
\fBrel([$base_url])\fP Returns the current object's URL relative to the base URL
23
\fBas_string()\fP Returns URL string (http://www.ru/news.htm)
25
\fBbase([base])\fP Sets/Gets base URL
27
\fBscheme([scheme])\fP Sets/Gets scheme(HTTP,FTP,...)
29
\fBnetloc([netloc])\fP Returns user:password@host:port string, or if it specified
30
sets apropriate parametrs
32
\fBhost([hostname])\fP Sets/Gets URL host name
34
\fBuser([user])\fP Sets/Gets user name
36
\fBpassword([passwd])\fP Sets/Gets user password
38
\fBport([port])\fP Sets/Gets port
40
\fBdefault_port([port]\fP Sets/Gets default port
42
\fBfull_path()\fP Returns a string consisting of the escaped path,
43
escaped parametrs, and escaped query string.
45
\fBepath([path])\fP Sets/Get escaped path of the URL
47
\fBpath([path])\fP Some but not escaped
49
\fBeparams([param])\fP Sets/Gets escaped parametrs of the URL
51
\fBparams([param])\fP Some but not escaped
53
\fBequery([query])\fP Sets/Gets escaped query string of the URL
55
\fBquery([query])\fP Some but not escaped
57
\fBfrag([frag])\fP Sets/Gets fragment of the URL
59
\fBcrack()\fP Returns an array with the following data: (scheme, user,
60
password, host, port, epath, eparms, equery, frag)
63
\fBeq(other_url)\fP Returns true when object's URL is equal to the specified URL
66
\fBuri_escape($uri|$str[,regexp])\fP By default
67
escapes RFC1738 characters, otherwise escape \fIregexp\fP characters.
69
\fBuri_unescape($uri)\fP Restores back
72
.===========================================================================
79
\fB$ua=new LWP::UserAgent\fP You give object a request, which it uses to
80
contact server and returns result.
83
\fBrequest($req,[file|$sub,size])\fP
85
Performs request. Returns the information
86
received from the server as an HTTP::Response object.
88
\fI$req\fP HTTP::Request object
90
\fIfile\fP Instead of return HTTP::Response object save all output to
93
\fI$sub\fP Reference to subroutine that will process data of the response.
94
If \fI'size'\fP argument used, the subroutine will be called any time that
95
number of bytes is recived as response data. Subroutine will get \fIresponse data\fP
96
as first argument, \fIHTTP::Response\fP as second and \fILWP::Protocol\fP as the third
99
\fBclone()\fP Returns a copy of the LWP::UserAgen object
101
\fBis_protocol_supported()\fP If true returned - LWP knows how to handle URL
102
with the specified protocol.
104
\fBcookie_jar([$cjar])\fP Specifies the HTTP::Cookies object to be used
106
\fBcredentials(netloc,realm,uname,pass)\fP
110
\fInetloc\fP Network location(usually URL) to which following apply
112
\fIrealm\fP The name of server-defined range of URLs that this data applies to
114
\fIuname\fP User name for authentication
116
\fIpass\fP Password for authentication (By default transmited with
121
\fBagent([agent])\fP Set/Get User-Agen in HTTP header
123
\fBtimeout[secs])\fP Set/Get request timeout (Def: 3min)
125
\fBmax_size[bytes])\fP Set/Get maximal size for response content (Def: No)
127
\fBfrom([email])\fP Set/Get E-Mail address for From header
129
\fBparse_head([bool])\fP Set/Get flag value indicating whether response
130
headers are initialized. (Def: true)
133
\fBproxy(prot,proxy)\fP Specifies proxy, first arg specify proxy protocol[http|ftp|...]
134
(may be either single protocol or list of protocols) and second proxy URL address.
136
\fBno_proxy(domains)\fP Don't use proxy for specified list of domains
138
\fBenv_proxy()\fP Use proxy parameters from HTTP_PROXY & NO_PROXY
142
\fBmirror(url,file)\fP Copies the contents of url into the file when the
143
length or modification date headers are different form any previous retrival.
144
Returns HTTP::Response object, where response code indicates what happened.
145
.========================================================================
151
\fB$err=get(url)\fP Returns contents of the specified url
153
\fB$err=getprint(url)\fP Prints contents of the url on stdout and
154
returns HTTP status code given by the server.
156
\fB$err=getstore(url,file)\fP Stores url into file and returns status
158
\fB$err=mirror(url,file)\fP Stores if url changed
160
\fBis_success($err)\fP Returns true if request was successful
162
\fBus_error($err)\fP Returns true if error occured
167
\fBhead(url)\fP Returns header information about specified url in the form:\fI ($content_type,
168
$document_length, $modified_time, $expires, $server)\fP
169
.==========================================================================
174
\fB$req=new HTTP::Request(method,url,[header,[content]])\fP
177
\fImethod:\fP HTTP request method (GET,HEAD,POST,PUT,DELETE)
179
\fIurl:\fP Either a string with absolute URL or URI::URL object
181
\fIHeader:\fP A reference to HTTP::Headers object
183
\fIContent:\fP Request content
186
\fBas_string()\fP Returns a text version of the request object
188
\fBmethod([method])\fP Set/Get HTTP method
190
\fBurl([url])\fP Set/Get URL
193
.========================================================================
198
\fB$resp=new HTTP::Response(rc,[msg,header,content])\fP
201
\fIrc\fP Response code(404,...)
203
\fImsg\fP Error message("Not found","Ok", ...)
205
\fIheader\fP Response header (HTTP::Header object)
207
\fIcontent\fP Response content
213
\fBas_string()\fP Returns a string version of response
215
\fBbase()\fP Returns base URL of the response. If the response was
216
HTML, any links from page should be relative to the location returned by this
217
method. (Looks for BASE tag or Content-Base/Content Location header, otherwise
221
\fBcurrent_age()\fP Returns number of seconds since response was generated
224
\fBfreshness_lifetime()\fP Returns number of seconds untill the response
227
\fBfresh_until()\fP Returns the time when the response expires(in: number of
230
\fBis_fresh()\fP Returns true if the response has not yet expired
233
\fBcode([code])\fP Set/Get response code
235
\fBmessage([msg])\fP Set/Get object status code message
237
\fBis_info()\fP True if response code in [100,199]
239
\fBis_success()\fP True if response code in [200,299]
241
\fBis_redirect()\fP True if response code in [300,399]
243
\fBis_error()\fP True if response code in [400,599]
245
\fBerror_as_HTML()\fP Returns HTML explanation of what happened
248
.========================================================================
254
\fB$h=new HTTP::Header([name => val],...)\fP
256
\fBclone()\fP Create a copy of the current object and returns reference to it
258
\fBheader(field[=>val],...)\fP Set/Get header fields values
260
\fBpush_header(field=>val)\fP Set new header field (old value are not removed!)
262
\fBremove_header(field)\fP Removes header field
264
\fBscan(\\&sub)\fP Invokes subroutin referenced by $sub for each header in
265
the object. The subroutine is passed the name of the header and its values as
266
a pair of arguments. For header fields with more than one value, the subroutine
267
will be called once for each value.
270
.============================================================================
272
Module is used to retrive, return, and manage cookies.
274
\fB$cjar=new HTTP::Cookies(file=>name,autosave=>1,ignore_discard=>0)\fP
278
\fIfile\fP File cookie to be loaded from(automaticaly)
280
\fIautosave\fP Save new cookies to file automaticaly
282
\fIignore_discard\fP Save to file discarded cookies
285
\fBas_string([discard])\fP Returns current content of the cookie jar as
286
a string.If discard is true, cookies marked as discarded will not be output.
288
\fBadd_cookie_header($req)\fP Adds appropriate Cookie header to HTTP::Request
289
(Searches cookie jar for any cookies matching the request URL and if they are
290
valid(not expired) are used to create Cookie headers.
292
\fBextract_cookies($resp)\fP Searches HTTP::Response for any Set-Cookie[2]
293
headers and store their information to cookie jar(hisself).
295
\fBload([file])\fP Loads cookie information from specified file(By default
296
from file specified during construction)
298
\fBsave([file])\fP Saves cookie information
300
\fBrevert()\fP Restores the cookie jar to its state before the last save
302
\fBclear([domain,path,name])\fP Deletes cookies belonging to specified domain,
303
path or name(All if parametr omitted)
305
\fBscan(\\&callback)\fP Invokes callback subroutine for each cookie in the jar.
306
Callback called with same options that are given to the set_cookie()
311
\fIversion,\fR the cookie-spec version number
313
\fIname,\fR cookie name
315
\fIval,\fR cookie value
317
\fIpath,\fR pathname of the URL for which the cookie is set
319
\fIdomain,\fR domain name for which cookie is set
321
\fIport,\fR pirt number for which cookie is set
323
\fIpath_spec,\fR boolean value indicating if the cookie valid for
324
specific URL path(true) or all the URLs in the domain.
326
\fIsecure,\fR boolean value indicating if cookie should only be sent over a
329
\fImaxage,\fR number of seconds that the cookie will be valid
331
\fIdiscard,\fR boolean, indicating that the cookie should not be sent in any
332
future requests and should be discarded upon saving the cookie jar.
334
\fI\\%misc)\fR Additional parametrs
335
.==========================================================================
337
Base class for HTTP::Request, HTTP::Response
342
\fBclone()\fP Creates copy of object & return reference to it
344
\fBadd_content(data)\fP Appends data to the end of the object's current entity body.
346
\fBcontent([cnt])\fP Set/Get content
348
\fBcontent_ref()\fP Returns reference to the string containig the content body
350
\fBheaders()\fP Returns embedded HTTP::Headers object from the message object
352
\fBprotocol([str])\fP Set/Get HTTP protocol string(something like HTTP/1.1)
355
.=============================================================================
b'\\ No newline at end of file'