summaryrefslogtreecommitdiff
path: root/src/rabbit_basic.erl
diff options
context:
space:
mode:
authorFrancesco Mazzoli <francesco@rabbitmq.com>2012-09-14 11:54:21 +0100
committerFrancesco Mazzoli <francesco@rabbitmq.com>2012-09-14 11:54:21 +0100
commitcd0ded1247c2b87825bb7418acdb8045d9bf004e (patch)
tree4741ad514c02f7c510dd1de14b0c38fadec2000b /src/rabbit_basic.erl
parentfafb014bb2251d210ed972ceda796bf425ae72ab (diff)
parentde8ebece1efd57e697ffe0a444c2c98ea64331cb (diff)
downloadrabbitmq-server-cd0ded1247c2b87825bb7418acdb8045d9bf004e.tar.gz
merge default
In particular, enforce the limit introduced in bug 24867 with per-message TTL too.
Diffstat (limited to 'src/rabbit_basic.erl')
-rw-r--r--src/rabbit_basic.erl23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl
index 734456d3..106cbbfa 100644
--- a/src/rabbit_basic.erl
+++ b/src/rabbit_basic.erl
@@ -20,7 +20,8 @@
-export([publish/4, publish/6, publish/1,
message/3, message/4, properties/1, append_table_header/3,
- extract_headers/1, map_headers/2, delivery/4, header_routes/1]).
+ extract_headers/1, map_headers/2, delivery/4, header_routes/1,
+ parse_expiration/1]).
-export([build_content/2, from_content/1]).
%%----------------------------------------------------------------------------
@@ -72,6 +73,9 @@
binary() | [binary()]) -> rabbit_types:content()).
-spec(from_content/1 :: (rabbit_types:content()) ->
{rabbit_framing:amqp_property_record(), binary()}).
+-spec(parse_expiration/1 ::
+ (rabbit_framing:amqp_property_record())
+ -> rabbit_types:ok_or_error2(non_neg_integer(), any())).
-endif.
@@ -226,3 +230,20 @@ header_routes(HeadersTable) ->
{Type, _Val} -> throw({error, {unacceptable_type_in_header,
binary_to_list(HeaderKey), Type}})
end || HeaderKey <- ?ROUTING_HEADERS]).
+
+parse_expiration(#'P_basic'{expiration = Expiration}) ->
+ case Expiration of
+ undefined -> {ok, undefined};
+ B -> case string:to_integer(binary_to_list(B)) of
+ {error, no_integer} = E ->
+ E;
+ {N, ""} ->
+ case rabbit_misc:check_expiry_size(N) of
+ ok -> {ok, N};
+ E = {error, _} -> E
+ end;
+ {_, S} ->
+ {error, {leftover_string, S}}
+ end
+ end.
+