You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Carl Eklof <ca...@yahoo.com> on 2005/11/18 23:14:19 UTC

Handling conditional-gets in embperl

Hey Guys,

I can see from google searches, that I'm re-hashing an
issue, but it wasn't solved in any of the posts and/or
doesn't work in the 2.0.0 embperl that I'm using.

I started out with the a frequently-referenced posting
from December 2000, by Gerald:
http://www2.ecos.de/~mailarc/embperl/2000-12/msg00001.html

I modified it to statically declare that everything
changes once a day (for testing)

I was doing ok setting the %http_headers_out, but once
I started trying to use the apache calls, nothing
seemed to work. The method calls don't actually set
the headers, and setting the status-code didn't set
the status-code. Handling conditional-get is a very
small piece of code. Has anybody gotten this to work
with 2.x?

Much appreciated,

-Carl

[!
	use POSIX qw(strftime);
	use Apache2::Response ();
	use Apache2::RequestRec;

	use Time::HiRes qw(gettimeofday tv_interval );
!]
[-

##########################################################################
	# Check, set expr date

##########################################################################
	my $do = GOB::DateRanges->new();

	# Always indicate that the page has changed every day
at 5am
	my $mod_time = $do->get_cday_begin();
	$mod_time += (3600 * 5); # add 5 hours

	my $expr_time = $mod_time + (3600 * 24); # expires
tomorrow morning
	my @etps = gmtime($expr_time);
	my $edate_str = strftime "%a, %d %b %Y %I:%M:00 GMT",
@etps;

	$http_headers_out{Expires} = $edate_str;

	print STDERR "got here a\n";

	$req_rec->update_mtime($mod_time);
	$req_rec->set_last_modified($mod_time);

	if ((my $rc = $req_rec->meets_conditions) != 200) { #
we can give up
		$req_rec->status($rc);
		print STDERR "got here b\n";
		#exit;
	}
-]


Carl Eklof 
President 
Bee Software LLC 
See us in action at:http://beethere.net/
p: 917.464.3529 
f: 801.439.4213
carl@beesw.com


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: Handling conditional-gets in embperl

Posted by Gerald Richter <ri...@ecos.de>.
> 	$req_rec->update_mtime($mod_time);
> 	$req_rec->set_last_modified($mod_time);
> 
> 	if ((my $rc = $req_rec->meets_conditions) != 200) { # 
> we can give up
> 		$req_rec->status($rc);
> 		print STDERR "got here b\n";
> 		#exit;

Try 

exit ($rc) ;

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org