Permalink
Browse files

add a test for the 'expires' directive

  • Loading branch information...
1 parent 4f3545f commit aab5243bd2c7ff62fbc9c9f4980f53c9f0baafdb @capflam capflam committed with vinoski May 27, 2011
Showing with 23 additions and 0 deletions.
  1. +1 −0 test/conf/stdconf.conf
  2. +22 −0 test/t2/app_test.erl
View
@@ -160,6 +160,7 @@ use_fdsrv = false
listen = 0.0.0.0
docroot = %YTOP%/www
auth_log = true
+ expires = <image/gif, access+2592000>
appmods = posttest
</server>
View
@@ -22,6 +22,7 @@ start() ->
sendfile_get(),
json_test(),
post_test(),
+ expires_test(),
ibrowse:stop().
@@ -562,6 +563,27 @@ large_chunked_post() ->
ok.
+expires_test() ->
+ io:format("expires_test\n", []),
+ Uri = "http://localhost:8006/icons/yaws.gif",
+ ?line {ok, "200", Hdrs, _} = ibrowse:send_req(Uri, [], get),
+
+ %% Retrieve max-age value to test Expires header
+ ?line "max-age=" ++ Rest = proplists:get_value("Cache-Control", Hdrs),
+ ?line Secs = list_to_integer(Rest),
+
+ %% Convert Date and Expires into datetime()
+ ?line Date = proplists:get_value("Date", Hdrs),
+ ?line Expires = proplists:get_value("Expires", Hdrs),
+ Date_DT = httpd_util:convert_request_date(Date),
+ Expires_DT = httpd_util:convert_request_date(Expires),
+
+ %% Check if Expires value is equal to "Date + max-age"
+ Val1 = calendar:datetime_to_gregorian_seconds(Date_DT) + Secs,
+ Val2 = calendar:datetime_to_gregorian_seconds(Expires_DT),
+ ?line Val1 = Val2,
+ ok.
+
%% used for appmod tests
%%
out(_A) ->

0 comments on commit aab5243

Please sign in to comment.