summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Mazzoli <francesco@rabbitmq.com>2012-09-17 15:57:09 +0100
committerFrancesco Mazzoli <francesco@rabbitmq.com>2012-09-17 15:57:09 +0100
commitd4fc4cbe253d6d6677d70c0a0f8b494a6cad69ba (patch)
tree94fcd44e9058a18a625766198f5123b685385814
parent709f2fdd04a9c4c84366c7ea9452f4a0073f6fd2 (diff)
downloadrabbitmq-server-d4fc4cbe253d6d6677d70c0a0f8b494a6cad69ba.tar.gz
refactor the check for the expiry out of `basic.publish'
-rw-r--r--src/rabbit_channel.erl15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 78f5d3b8..ab13b2fe 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -470,6 +470,14 @@ check_user_id_header(#'P_basic'{user_id = Claimed},
"user_id property set to '~s' but authenticated user was '~s'",
[Claimed, Actual]).
+check_expiration_header(Props) ->
+ case rabbit_basic:parse_expiration(Props) of
+ {ok, _} -> ok;
+ {error, E} -> rabbit_misc:protocol_error(
+ invalid_expiration, "cannot parse expiration '~p': ~p",
+ [Props#'P_basic'.expiration, E])
+ end.
+
check_internal_exchange(#exchange{name = Name, internal = true}) ->
rabbit_misc:protocol_error(access_refused,
"cannot publish to internal ~s",
@@ -611,12 +619,7 @@ handle_method(#'basic.publish'{exchange = ExchangeNameBin,
DecodedContent = #content {properties = Props} =
rabbit_binary_parser:ensure_content_decoded(Content),
check_user_id_header(Props, State),
- case rabbit_basic:parse_expiration(Props) of
- {ok, _} -> ok;
- {error, E} -> rabbit_misc:protocol_error(
- invalid_expiration, "cannot parse expiration '~p': ~p",
- [Props#'P_basic'.expiration, E])
- end,
+ check_expiration_header(Props),
{MsgSeqNo, State1} =
case {TxStatus, ConfirmEnabled} of
{none, false} -> {undefined, State};