Skip to content

Commit

Permalink
Move to 0.2.5 - including more headers to stop cacheing & force a clo…
Browse files Browse the repository at this point in the history
…se on the connection which should fix the proxypass issue: \!1
  • Loading branch information
IanCal committed Jun 22, 2012
1 parent 4387b9c commit 09928f0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sinan.config
@@ -1,5 +1,5 @@
{project_name, semq}.
{project_vsn, "0.2.4"}.
{project_vsn, "0.2.5"}.

{build_dir, "_build"}.

Expand Down
1 change: 1 addition & 0 deletions src/messagequeue.erl
Expand Up @@ -67,6 +67,7 @@ queue(Messages) ->
returnnextadd(Pid) ->
receive
{get, PidReturn} ->
Pid ! {error, new_client},
returnnextadd(PidReturn);
{add, Message} ->
Pid ! {ok, Message},
Expand Down
2 changes: 1 addition & 1 deletion src/semq.app.src
Expand Up @@ -2,7 +2,7 @@
%% application.
{application, semq,
[{description, "A simple message queue implementation accessible via POST and GET with an extremely small API"},
{vsn, "0.2.4"},
{vsn, "0.2.5"},
{modules, [semq_app,
semq_sup]},
{registered,[semq_sup]},
Expand Down
13 changes: 10 additions & 3 deletions src/semq_web.erl
Expand Up @@ -50,7 +50,8 @@ queue_get_head(Queue, Req) ->
frontend:removehead(Queue),
{ok, {Type, Message}, Req};
_ ->
error_logger:error_report(["client disconnected"])
error_logger:error_report(["client disconnected"]),
{ok, {"text/plain", ""}, Req}
end;
{error, Reason} ->
{error, Reason}
Expand Down Expand Up @@ -85,7 +86,13 @@ reply(Status, MimeType, Body, Req) ->
cowboy_http_req:reply(Status2, headerswithtype(MimeType2), WrappedBody, Req2).

headerswithtype(Mimetype) ->
[{<<"Access-Control-Allow-Headers">>, <<"Content-Type">>}, {<<"Access-Control-Allow-Origin">>, <<"*">>}, {<<"Content-Type">>, Mimetype}].
[{<<"Access-Control-Allow-Headers">>, <<"Content-Type">>},
{<<"Access-Control-Allow-Origin">>, <<"*">>},
{<<"Content-Type">>, Mimetype},
{<<"Connection">>, <<"close">>},
{<<"Cache-Control">>, <<"max-age=0, no-cache, no-store, must-revalidate">>},
{<<"Pragma">>, <<"no-cache">>},
{<<"Expires">>, <<"Wed, 11 Jan 1984 05:00:00 GMT">>}].


handle_method('GET', Req) ->
Expand All @@ -102,7 +109,7 @@ handle_method('POST', Req) ->
{Path, Req} = cowboy_http_req:path(Req),
{ok, Queues} = extract_queue_names(Path),
{ok, {Type, Message}, Req2} = queue_post(Queues, Req),
cowboy_http_req:reply(200, headerswithtype(Type), Message, Req2);
cowboy_http_req:reply(200, headerswithtype(Type), Message, Req2);

handle_method('HEAD', Req) ->
cowboy_http_req:reply(200, headerswithtype(<<"text/plain">>), <<"">>, Req);
Expand Down

0 comments on commit 09928f0

Please sign in to comment.