/[pub]/suikawiki/script/lib/SuikaWiki/Input/HTTP.pm
Suika

Contents of /suikawiki/script/lib/SuikaWiki/Input/HTTP.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Sun Jul 25 06:54:29 2004 UTC (22 years ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, HEAD
Branch point for: helowiki, helowiki-2005
Changes since 1.6: +3 -3 lines
Property Editor implemented

1
2 =head1 NAME
3
4 SuikaWiki::Input::HTTP - SuikaWiki: HTTP or HTTP CGI input support
5
6 =head1 DESCRIPTION
7
8 This module provides HTTP or HTTP CGI input support,
9 although current version of this module supports HTTP CGI only.
10
11 This module is part of SuikaWiki.
12
13 =cut
14
15 package SuikaWiki::Input::HTTP;
16 use strict;
17 our $VERSION = do{my @r=(q$Revision: 1.6 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
18
19 =head1 METHODS
20
21 =over 4
22
23 =item $http = SuikaWiki::Input::HTTP->new
24
25 Constructs new instance of HTTP input implementation
26
27 =cut
28
29 sub new ($;%) {
30 my $self = bless {
31 decoder => {
32 '#default' => sub {$_[1]},
33 },
34 }, shift;
35 my %opt = @_;
36 $self->{wiki} = $opt{wiki};
37 $self->{-in_handle} = $opt{input_handle} || *STDIN;
38 $self;
39 }
40
41 =item $value = $http->meta_variable ($name)
42
43 Returns variable value. $name should be a meta-variable name
44 defined by CGI specification, eg. CONTENT_TYPE, HTTP_USER_AGENT and so on.
45
46 =cut
47
48 sub meta_variable ($$) {
49 $main::ENV{ $_[1] };
50 }
51
52 =item @list = $http->meta_variable_list
53
54 Returns list of meta variables. Note that this list might contain
55 other environmental variables than CGI meta variables, since
56 they cannot distinglish unless we know what is CGI meta variable
57 and what is not. Unfortunately, there is no complete list of CGI
58 meta variables, whilst list of standarized meta variables is available.
59
60 Future version of this module, which implements non-CGI HTTP request,
61 will not return non-CGI environmental variable names in non-CGI mode.
62
63 NOTE: Some application might use an environmental variable named
64 'HTTP_HOME', which might make some confusion with CGI meta variable
65 for HTTP 'Home:' header field. Fortunately, such name of HTTP
66 header field is not intoroduced as far as I know.
67
68 =cut
69
70 sub meta_variable_list ($) {
71 keys %main::ENV;
72 }
73
74 =item $value = $http->parameter ($name)
75
76 Returns parameter value if any.
77 Parameter value is set by query-string of Request-URI
78 and/or entity-body value.
79
80 When multiple values with same parameter name is specified,
81 the first one is returned in scalar context or
82 an array reference of all values is returned in array context.
83 (Note that query-string is "earlier" than entity-body.)
84
85 =item @keys = $http->parameter_names
86
87 Returnes a list of parameter names provided.
88
89 =cut
90
91 sub parameter ($$) {
92 my ($self, $name) = @_;
93 $self->__get_parameter unless $self->{param};
94