Erlang/OTP Forums

Author Message

<  Yaws mailing list  ~  possible if-modified-since patch

Guest
Posted: Sat Feb 16, 2008 6:25 pm Reply with quote
Guest
I noticed using curl that sending Yaws an If-modified-since header
containing the Last-modified value returned from a previous call would
not result in a 304 Not Modified. The patch below contains a possible
fix for that.

--steve


Index: src/yaws_server.erl
===================================================================
--- src/yaws_server.erl (revision 1218)
+++ src/yaws_server.erl (working copy)
@@ -1627,12 +1627,25 @@
case H#headers.if_none_match of
undefined ->
case H#headers.if_match of
- undefined ->
- yaws:outh_set_static_headers
- (Req, UT, H, Range),
- deliver_file
- (CliSock, Req, UT, Range);
-
+ undefined ->
+ case H#headers.if_modified_since of
+ undefined ->
+ yaws:outh_set_static_headers
+ (Req, UT, H, Range),
+ deliver_file
+ (CliSock, Req, UT, Range);
+ UTC_string ->
+ case
yaws:is_modified_p(UT#urltype.finfo, UTC_string) of
+ true ->
+
yaws:outh_set_static_headers
+ (Req, UT, H, Range),
+
deliver_file(CliSock, Req, UT, Range);
+ false ->
+
yaws:outh_set_304_headers(Req, UT, H),
+
deliver_accumulated(CliSock),
+ done_or_continue()
+ end
+ end;
Line ->
case member(ETag,
yaws:split_sep(Line, $,)) of
@@ -1750,7 +1763,8 @@
case yaws:outh_get_doclose() of
true -> done;
false -> continue;
- keep_alive -> continue
+ keep_alive -> continue;
+ undefined -> continue
end.


Index: src/yaws.erl
===================================================================
--- src/yaws.erl (revision 1218)
+++ src/yaws.erl (working copy)
@@ -29,6 +29,7 @@
ssl_cacertfile/1, ssl_cacertfile/2,
ssl_ciphers/1, ssl_ciphers/2,
ssl_cachetimeout/1, ssl_cachetimeout/2]).
+-export([is_modified_p/2]).

-import(lists, [reverse/1, reverse/2]).

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist
Guest
Posted: Sun Feb 17, 2008 6:08 pm Reply with quote
Guest
Steve Vinoski wrote:
> I noticed using curl that sending Yaws an If-modified-since header
> containing the Last-modified value returned from a previous call would
> not result in a 304 Not Modified. The patch below contains a possible
> fix for that.
>

Brilliant,

Applied in trunk

/klacke

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum