49
49
% % we grant depending on how fast target queue(s) actually confirm messages.
50
50
-define (LINK_CREDIT_RCV , 128 ).
51
51
52
+ % % Pure HTTP clients of a future HTTP API (v2) would call endpoints as follows:
53
+ % % GET /v2/vhosts/:vhost/queues/:queue
54
+ % %
55
+ % % Here, we use the terminus address /management/v2 so that AMQP 1.0 clients declare the HTTP API version
56
+ % % at link attachment time. The vhost is already determined at AMQP connection open time.
57
+ % % Therefore, there is no need to send the HTTP API version and the vhost in every HTTP over AMQP request.
58
+ -define (MANAGEMENT_NODE_ADDRESS , <<" /management/v2" >>).
59
+
52
60
-export ([start_link /8 ,
53
61
process_frame /2 ,
54
62
list_local /0 ,
@@ -735,7 +743,7 @@ handle_control(#'v1_0.attach'{
735
743
name = Name = {utf8 , LinkName },
736
744
handle = Handle = ? UINT (HandleInt ),
737
745
source = Source = # 'v1_0.source' {address = ClientTerminusAddress },
738
- target = Target = # 'v1_0.target' {address = {utf8 , << " $management " >> }},
746
+ target = Target = # 'v1_0.target' {address = {utf8 , ? MANAGEMENT_NODE_ADDRESS }},
739
747
initial_delivery_count = DeliveryCount = ? UINT (DeliveryCountInt ),
740
748
properties = Properties
741
749
} = Attach ,
@@ -792,7 +800,7 @@ handle_control(#'v1_0.attach'{
792
800
role = ? AMQP_ROLE_RECEIVER ,
793
801
name = Name = {utf8 , LinkName },
794
802
handle = Handle = ? UINT (HandleInt ),
795
- source = Source = # 'v1_0.source' {address = {utf8 , << " $management " >> }},
803
+ source = Source = # 'v1_0.source' {address = {utf8 , ? MANAGEMENT_NODE_ADDRESS }},
796
804
target = Target = # 'v1_0.target' {address = ClientTerminusAddress },
797
805
rcv_settle_mode = RcvSettleMode ,
798
806
max_message_size = MaybeMaxMessageSize ,
@@ -1680,7 +1688,7 @@ incoming_mgmt_link_transfer(
1680
1688
Settled = default (MaybeSettled , false ),
1681
1689
validate_transfer_rcv_settle_mode (RcvSettleMode , Settled ),
1682
1690
validate_message_size (Request , IncomingMaxMessageSize ),
1683
- Response = rabbit_amqp_management :process_request (Request , Vhost , User , ReaderPid ),
1691
+ Response = rabbit_amqp_management :handle_request (Request , Vhost , User , ReaderPid ),
1684
1692
1685
1693
Transfer = # 'v1_0.transfer' {
1686
1694
handle = ? UINT (OutgoingHandleInt ),
@@ -1690,7 +1698,7 @@ incoming_mgmt_link_transfer(
1690
1698
settled = true },
1691
1699
? DEBUG (" ~s Outbound content:~n ~tp~n " ,
1692
1700
[? MODULE , [amqp10_framing :pprint (Section ) ||
1693
- Section <- amqp10_framing :decode_bin (iolist_to_binary (Respon ))]]),
1701
+ Section <- amqp10_framing :decode_bin (iolist_to_binary (Response ))]]),
1694
1702
validate_message_size (Response , OutgoingMaxMessageSize ),
1695
1703
Frames = transfer_frames (Transfer , Response , MaxFrameSize ),
1696
1704
PendingTransfer = # pending_management_transfer {frames = Frames },
@@ -1917,7 +1925,7 @@ ensure_target(#'v1_0.target'{address = Address,
1917
1925
{ok , Dest } ->
1918
1926
QNameBin = ensure_terminus (target , Dest , Vhost , User , Durable ),
1919
1927
{XNameList1 , RK } = rabbit_routing_parser :parse_routing (Dest ),
1920
- XNameBin = list_to_binary (XNameList1 ),
1928
+ XNameBin = unicode : characters_to_binary (XNameList1 ),
1921
1929
XName = rabbit_misc :r (Vhost , exchange , XNameBin ),
1922
1930
{ok , X } = rabbit_exchange :lookup (XName ),
1923
1931
check_internal_exchange (X ),
@@ -1933,7 +1941,7 @@ ensure_target(#'v1_0.target'{address = Address,
1933
1941
RoutingKey = case RK of
1934
1942
undefined -> undefined ;
1935
1943
[] -> undefined ;
1936
- _ -> list_to_binary (RK )
1944
+ _ -> unicode : characters_to_binary (RK )
1937
1945
end ,
1938
1946
{ok , Exchange , RoutingKey , QNameBin };
1939
1947
{error , _ } = E ->
@@ -2117,8 +2125,8 @@ ensure_source(#'v1_0.source'{address = Address,
2117
2125
true = string :equal (QNameList , QNameBin ),
2118
2126
{ok , QNameBin };
2119
2127
{XNameList , RoutingKeyList } ->
2120
- RoutingKey = list_to_binary (RoutingKeyList ),
2121
- XNameBin = list_to_binary (XNameList ),
2128
+ RoutingKey = unicode : characters_to_binary (RoutingKeyList ),
2129
+ XNameBin = unicode : characters_to_binary (XNameList ),
2122
2130
XName = rabbit_misc :r (Vhost , exchange , XNameBin ),
2123
2131
QName = rabbit_misc :r (Vhost , queue , QNameBin ),
2124
2132
Binding = # binding {source = XName ,
@@ -2322,19 +2330,19 @@ ensure_terminus(target, {queue, undefined}, _, _, _) ->
2322
2330
% % Default exchange exists.
2323
2331
undefined ;
2324
2332
ensure_terminus (_ , {queue , QNameList }, Vhost , User , Durability ) ->
2325
- declare_queue (list_to_binary (QNameList ), Vhost , User , Durability );
2333
+ declare_queue (unicode : characters_to_binary (QNameList ), Vhost , User , Durability );
2326
2334
ensure_terminus (_ , {amqqueue , QNameList }, Vhost , _ , _ ) ->
2327
2335
% % Target "/amq/queue/" is handled specially due to AMQP legacy:
2328
2336
% % "Queue names starting with "amq." are reserved for pre-declared and
2329
2337
% % standardised queues. The client MAY declare a queue starting with "amq."
2330
2338
% % if the passive option is set, or the queue already exists."
2331
- QNameBin = list_to_binary (QNameList ),
2339
+ QNameBin = unicode : characters_to_binary (QNameList ),
2332
2340
ok = exit_if_absent (queue , Vhost , QNameBin ),
2333
2341
QNameBin .
2334
2342
2335
- exit_if_absent (Type , Vhost , Name ) ->
2336
- ResourceName = rabbit_misc :r (Vhost , Type , rabbit_data_coercion : to_binary (Name )),
2337
- Mod = case Type of
2343
+ exit_if_absent (Kind , Vhost , Name ) ->
2344
+ ResourceName = rabbit_misc :r (Vhost , Kind , unicode : characters_to_binary (Name )),
2345
+ Mod = case Kind of
2338
2346
exchange -> rabbit_exchange ;
2339
2347
queue -> rabbit_amqqueue
2340
2348
end ,
0 commit comments