Home > Archive > PERL CGI Beginners > February 2005 > Content_Length
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| I have like 20 variable coming from a form, using CGI.pm in my script.
I am at a loss as how to get $ENV{'Content_lenght'} for all of those collectively. Is there anything in CGI.pm for it?. I am trying to count every keystroke that user inputs to form.
Thanks,
Sara.
| |
| Sean Davis 2005-02-03, 3:55 pm |
| Content length includes all the content, including names of form
parameters, etc. If you want to count the keystrokes for a form, you
could just run through the form parameters and get the length of each
value (assuming they are all text fields). Check out these two links
to the CGI.pm documentation:
http://cpan.uwinnipeg.ca/htdocs/CGI.pm/
CGI. html#fetching_the_names_of_all_the_param
eters_passed_to_your_script_
http://cpan.uwinnipeg.ca/htdocs/CGI.pm/
CGI. html#fetching_the_parameter_list_as_a_ha
sh_
Hope that helps.
Sean
On Feb 3, 2005, at 7:56 AM, Sara wrote:
> I have like 20 variable coming from a form, using CGI.pm in my script.
>
> I am at a loss as how to get $ENV{'Content_lenght'} for all of those
> collectively. Is there anything in CGI.pm for it?. I am trying to count
> every keystroke that user inputs to form.
>
> Thanks,
> Sara.
| |
| Zentara 2005-02-04, 3:55 pm |
| On Thu, 3 Feb 2005 17:56:19 +0500, sara_samsara@hotpop.com (Sara) wrote:
>I have like 20 variable coming from a form, using CGI.pm in my script.
>
>I am at a loss as how to get $ENV{'Content_lenght'} for all of those collectively. Is there anything in CGI.pm for it?. I am trying to count every keystroke that user inputs to form.
>
>Thanks,
>Sara.
You don't need CGI.pm just to get the CONTENT_LENGTH.
if($ENV{CONTENT_LENGTH} > $maxsize){
print "incoming data too large - must be less than $maxsize bytes";
exit;
}
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
| |
| kevindotcar 2005-02-08, 3:55 pm |
|
Sara wrote:
> I have like 20 variable coming from a form, using CGI.pm in my
script.
>
> I am at a loss as how to get $ENV{'Content_lenght'} for all of those
collectively. Is there anything in CGI.pm for it?. I am trying to count
every keystroke that user inputs to form.
>
> Thanks,
> Sara.
Hi Sara,
If you're asking for the length of the entire query string, that's
just this;
my($qlen) = length($query->query_string);
If you're trying to get the length of ALL server-returned
data, maybe something like this;
$the_string = $query->query_string;
@vars = split(/;/, $the_string);
my($cont_len) = 0;
foreach $var (@vars) {
($v,$i) = split(/=/, $var);
$v =~ tr/+/ /;
$v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$i =~ tr/+/ /;
$i =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$i =~ s/<!--(.|\n)*-->//g;
$INFO{$v} = $i;
$cont_len += $i;
}
And, you'd reference the vars with something like;
my($user) = $INFO{'USER'};
Notice the translation for HTTP-returned chars- Your mileage
may vary- I don't think I got all of them, so ask an expert.
and the length of all server-returned user-input
(sans variable-names would be in $cont_len;
HTH
K.C
in
|
|
|
|
|