Re: $r-header_only question (feeling a newbie!)

2000-10-03 Thread martin langhoff

 martin,
 check out:
 http://www.ora.com/catalog/wrapmod/errata/wrapmod.699

Well, I guess fair is fair, the correction for page 146 (unless = if)
was there,  I should've done my research better ... 

anyway I do seem to be needing 'use Apache::Constants qw(:common);' to
run under strict and ^W=1 ... 



martin



Re: $r-header_only question (feeling a newbie!)

2000-10-03 Thread Vivek Khera

 "DT" == Drew Taylor [EMAIL PROTECTED] writes:

DT after changing "unless" to "if". Can anyone check what Apache defaults
DT to if no status code is returned? I'm guessing it's "OK". 

In perl, if you have no explicit return statement, the last value
computed (or returned from another sub call) will be returned.  You
must explicitly issue a return if you want specific behavior.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.Khera Communications, Inc.
Internet: [EMAIL PROTECTED]   Rockville, MD   +1-301-545-6996
GPG  MIME spoken herehttp://www.khera.org/~vivek/



$r-header_only question (feeling a newbie!)

2000-10-02 Thread martin langhoff

hi,

I've been developing with mod_perl for a while, but, thanks to
Richter's Embperl module and the excellent backwards compatibility
(regarding CGI.pm) I had never got anywhere near Apache::Request -- for
production, that is. 

Now I have this very silly question, that I've boiled down to this
little snippet of code (which carries a remakable resemblance to the
example found in page 146 of the Eagle Book):
--
#!/usr/bin/perl -w 
use strict;
use Apache::Constants qw(:common); 

my $r = Apache-request;
$r-content_type('text/html');
$r-send_http_header;

return OK unless $r-header_only; # THIS is the line I'm wondering about

$r-print(END);
htmlbodyh1 Hello ! /h1
address martin/address/body/html
END
1;



The issue is that I don't understand clearly what is this line supposed
to do. As it is, it'll make my script return an empty body ('document
contains no data!' said Navigator). Commented out, the proper contents
are sent. Reading the Eagle and `man Apache::Request` led me to thing
that the line is there to stop processing if all the client wants are
the headers (maybe because of a 'If-Modified-Since' parameter?). 

Now  shouldn't it be an 'if' instead of an 'unless'?

Am I too dumb today? Or is it just that it's monday?



martin



Re: $r-header_only question (feeling a newbie!)

2000-10-02 Thread Drew Taylor

martin langhoff wrote:
 
 hi,
 
 I've been developing with mod_perl for a while, but, thanks to
 Richter's Embperl module and the excellent backwards compatibility
 (regarding CGI.pm) I had never got anywhere near Apache::Request -- for
 production, that is.
 
 Now I have this very silly question, that I've boiled down to this
 little snippet of code (which carries a remakable resemblance to the
 example found in page 146 of the Eagle Book):
 --
 #!/usr/bin/perl -w
 use strict;
 use Apache::Constants qw(:common);
 
 my $r = Apache-request;
 $r-content_type('text/html');
 $r-send_http_header;
 
 return OK unless $r-header_only; # THIS is the line I'm wondering about
 
 $r-print(END);
 htmlbodyh1 Hello ! /h1
 address martin/address/body/html
 END
 1;
 
 
 
 The issue is that I don't understand clearly what is this line supposed
 to do. As it is, it'll make my script return an empty body ('document
 contains no data!' said Navigator). Commented out, the proper contents
 are sent. Reading the Eagle and `man Apache::Request` led me to thing
 that the line is there to stop processing if all the client wants are
 the headers (maybe because of a 'If-Modified-Since' parameter?).

I believe all you need to add is "return OK;" after your print
statement. Without that, Apache doesn't know what the status of the
request should be.

-- 
Drew Taylor
Software Engineer
Phone: 617.351.0245
Fax 617.350.3496
OpenAir.com - Making Business a Breeze!
Open a free account today at www.openair.com



Re: $r-header_only question (feeling a newbie!)

2000-10-02 Thread Tim Tompkins

This should be an "if" instead of "unless"

return OK if $r-header_only;

header_only() will return true if the request method is HEAD.  You'll want
to simply return OK once you've gathered all the necessary outgoing headers
for HEAD requests.



Thanks,

Tim Tompkins
--
Programmer / Staff Engineer
http://www.arttoday.com/
--
- Original Message -
From: "martin langhoff" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, October 02, 2000 1:37 PM
Subject: $r-header_only question (feeling a newbie!)


 hi,

 I've been developing with mod_perl for a while, but, thanks to
 Richter's Embperl module and the excellent backwards compatibility
 (regarding CGI.pm) I had never got anywhere near Apache::Request -- for
 production, that is.

 Now I have this very silly question, that I've boiled down to this
 little snippet of code (which carries a remakable resemblance to the
 example found in page 146 of the Eagle Book):
 --
 #!/usr/bin/perl -w
 use strict;
 use Apache::Constants qw(:common);

 my $r = Apache-request;
 $r-content_type('text/html');
 $r-send_http_header;

 return OK unless $r-header_only; # THIS is the line I'm wondering about

 $r-print(END);
 htmlbodyh1 Hello ! /h1
 address martin/address/body/html
 END
 1;

 

 The issue is that I don't understand clearly what is this line supposed
 to do. As it is, it'll make my script return an empty body ('document
 contains no data!' said Navigator). Commented out, the proper contents
 are sent. Reading the Eagle and `man Apache::Request` led me to thing
 that the line is there to stop processing if all the client wants are
 the headers (maybe because of a 'If-Modified-Since' parameter?).

 Now  shouldn't it be an 'if' instead of an 'unless'?

 Am I too dumb today? Or is it just that it's monday?



 martin





Re: $r-header_only question (feeling a newbie!)

2000-10-02 Thread martin langhoff

... it made no difference ... :(

Drew Taylor wrote:
 I believe all you need to add is "return OK;" after your print
 statement. Without that, Apache doesn't know what the status of the
 request should be.



Re: $r-header_only question (feeling a newbie!)

2000-10-02 Thread Drew Taylor

martin langhoff wrote:
 
 ... it made no difference ... :(
 
 Drew Taylor wrote:
  I believe all you need to add is "return OK;" after your print
  statement. Without that, Apache doesn't know what the status of the
  request should be.

Doh. I missed what Tim caught. I believe Apache will assume an "OK" if
you don't explicitly return a status code. Thus your code _should_ work
after changing "unless" to "if". Can anyone check what Apache defaults
to if no status code is returned? I'm guessing it's "OK". 

However, I'd still add a return OK after the print. :-)

-- 
Drew Taylor
Software Engineer
Phone: 617.351.0245
Fax 617.350.3496
OpenAir.com - Making Business a Breeze!
Open a free account today at www.openair.com



Re: $r-header_only question (feeling a newbie!)

2000-10-02 Thread Doug MacEachern

On Mon, 2 Oct 2000, martin langhoff wrote:

   Now  shouldn't it be an 'if' instead of an 'unless'?

yes, it should be an `if'.  your script works fine for me with that
change.




Re: $r-header_only question (feeling a newbie!)

2000-10-02 Thread martin langhoff

Thanks Tim and all,

my gathering is that the sample script on page 146 of the Eagle:
- needed a 'use Apache::Constants(:common);' line
- needed a 'return OK;' line at EOF
- had an 'unless' that should've been an 'if'.

for-the-record, I did check www.modperl.com looking for an
errata.
Doug? Lincoln? I mean, it's one of the *simple* scripts, I do LOVE the
book, but I guess I'll have to trust this list a hunderd times more than
the book.

And, unless it was all my mistake, for some unbeknownst reason,
a few
marks down for O'Reilly technical reviewers :p


martin

Tim Tompkins wrote:
 
 This should be an "if" instead of "unless"
 
 return OK if $r-header_only;
 
 header_only() will return true if the request method is HEAD.  You'll want
 to simply return OK once you've gathered all the necessary outgoing headers
 for HEAD requests.



Re: $r-header_only question (feeling a newbie!)

2000-10-02 Thread ___cliff rayman___

doug, lincoln,
looks like www.modperl.com needs a link to errata.

martin,
check out:
http://www.ora.com/catalog/wrapmod/errata/wrapmod.699

martin langhoff wrote:

 Thanks Tim and all,
 for-the-record, I did check www.modperl.com looking for an
 errata.

 marks down for O'Reilly technical reviewers :p

 martin

 Tim Tompkins wrote:
 
  This should be an "if" instead of "unless"
 
  return OK if $r-header_only;
 
  header_only() will return true if the request method is HEAD.  You'll want
  to simply return OK once you've gathered all the necessary outgoing headers
  for HEAD requests.

--
___cliff [EMAIL PROTECTED]http://www.genwax.com/