@@ -17,28 +17,26 @@ handle_request(Request, Vhost, User, ConnectionPid) ->
17
17
% % see Link Pair CS 01 §2.1
18
18
% % https://docs.oasis-open.org/amqp/linkpair/v1.0/cs01/linkpair-v1.0-cs01.html#_Toc51331305
19
19
reply_to = {utf8 , <<" $me" >>}},
20
- ReqBin
20
+ ReqPayload
21
21
} = decode_req (ReqSections , {undefined , undefined }),
22
22
{PathSegments , QueryMap } = parse_uri (HttpRequestTarget ),
23
- ReqPayload = amqp10_framing :decode_bin (ReqBin ),
24
23
{RespProps0 ,
25
24
RespAppProps0 = # 'v1_0.application_properties' {content = C },
26
- RespPayload } = handle_http_req (HttpMethod ,
27
- PathSegments ,
28
- QueryMap ,
29
- ReqPayload ,
30
- Vhost ,
31
- User ,
32
- ConnectionPid ),
25
+ RespBody } = handle_http_req (HttpMethod ,
26
+ PathSegments ,
27
+ QueryMap ,
28
+ ReqPayload ,
29
+ Vhost ,
30
+ User ,
31
+ ConnectionPid ),
33
32
RespProps = RespProps0 # 'v1_0.properties' {
34
33
% % "To associate a response with a request, the correlation-id value of the response
35
34
% % properties MUST be set to the message-id value of the request properties."
36
35
% % [HTTP over AMQP WD 06 §5.1]
37
36
correlation_id = MessageId },
38
37
RespAppProps = RespAppProps0 # 'v1_0.application_properties' {
39
38
content = [{{utf8 , <<" http:response" >>}, {utf8 , <<" 1.1" >>}} | C ]},
40
- RespBody = iolist_to_binary (amqp10_framing :encode_bin (RespPayload )),
41
- RespDataSect = # 'v1_0.amqp_value' {content = {binary , RespBody }},
39
+ RespDataSect = # 'v1_0.amqp_value' {content = RespBody },
42
40
RespSections = [RespProps , RespAppProps , RespDataSect ],
43
41
[amqp10_framing :encode_bin (Sect ) || Sect <- RespSections ].
44
42
@@ -49,7 +47,7 @@ handle_request(Request, Vhost, User, ConnectionPid) ->
49
47
handle_http_req (<<" PUT" >>,
50
48
[<<" queues" >>, QNameBinQ ],
51
49
_Query ,
52
- [ ReqPayload ] ,
50
+ ReqPayload ,
53
51
Vhost ,
54
52
# user {username = Username },
55
53
ConnPid ) ->
@@ -70,13 +68,13 @@ handle_http_req(<<"PUT">>,
70
68
{new , _Q } = rabbit_queue_type :declare (Q0 , node ()),
71
69
Props = # 'v1_0.properties' {subject = {utf8 , <<" 201" >>}},
72
70
AppProps = # 'v1_0.application_properties' {content = []},
73
- RespPayload = undefined ,
71
+ RespPayload = null ,
74
72
{Props , AppProps , RespPayload };
75
73
76
74
handle_http_req (<<" PUT" >>,
77
75
[<<" exchanges" >>, XNameBinQ ],
78
76
_Query ,
79
- [ ReqPayload ] ,
77
+ ReqPayload ,
80
78
Vhost ,
81
79
# user {username = Username },
82
80
_ConnPid ) ->
@@ -98,13 +96,13 @@ handle_http_req(<<"PUT">>,
98
96
Username ),
99
97
Props = # 'v1_0.properties' {subject = {utf8 , <<" 201" >>} },
100
98
AppProps = # 'v1_0.application_properties' {content = []},
101
- RespPayload = undefined ,
99
+ RespPayload = null ,
102
100
{Props , AppProps , RespPayload };
103
101
104
102
handle_http_req (<<" DELETE" >>,
105
103
[<<" queues" >>, QNameBinQ , <<" messages" >>],
106
104
_Query ,
107
- [ undefined ] ,
105
+ null ,
108
106
Vhost ,
109
107
_User ,
110
108
ConnPid ) ->
@@ -123,7 +121,7 @@ handle_http_req(<<"DELETE">>,
123
121
handle_http_req (<<" DELETE" >>,
124
122
[<<" queues" >>, QNameBinQ ],
125
123
_Query ,
126
- [ undefined ] ,
124
+ null ,
127
125
Vhost ,
128
126
# user {username = Username },
129
127
ConnPid ) ->
@@ -138,7 +136,7 @@ handle_http_req(<<"DELETE">>,
138
136
handle_http_req (<<" DELETE" >>,
139
137
[<<" exchanges" >>, XNameBinQ ],
140
138
_Query ,
141
- [ undefined ] ,
139
+ null ,
142
140
Vhost ,
143
141
# user {username = Username },
144
142
_ConnPid ) ->
@@ -154,13 +152,13 @@ handle_http_req(<<"DELETE">>,
154
152
end ,
155
153
Props = # 'v1_0.properties' {subject = {utf8 , <<" 204" >>}},
156
154
AppProps = # 'v1_0.application_properties' {content = []},
157
- RespPayload = undefined ,
155
+ RespPayload = null ,
158
156
{Props , AppProps , RespPayload };
159
157
160
158
handle_http_req (<<" POST" >>,
161
159
[<<" bindings" >>],
162
160
_Query ,
163
- [ ReqPayload ] ,
161
+ ReqPayload ,
164
162
Vhost ,
165
163
# user {username = Username },
166
164
_ConnPid ) ->
@@ -185,13 +183,13 @@ handle_http_req(<<"POST">>,
185
183
Location = compose_binding_uri (SrcXNameBin , DstKind , DstNameBin , BindingKey , Args ),
186
184
AppProps = # 'v1_0.application_properties' {
187
185
content = [{{utf8 , <<" location" >>}, {utf8 , Location }}]},
188
- RespPayload = undefined ,
186
+ RespPayload = null ,
189
187
{Props , AppProps , RespPayload };
190
188
191
189
handle_http_req (<<" DELETE" >>,
192
190
[<<" bindings" >>, BindingSegment ],
193
191
_Query ,
194
- [ undefined ] ,
192
+ null ,
195
193
Vhost ,
196
194
# user {username = Username },
197
195
_ConnPid ) ->
@@ -207,14 +205,14 @@ handle_http_req(<<"DELETE">>,
207
205
end ,
208
206
Props = # 'v1_0.properties' {subject = {utf8 , <<" 204" >>}},
209
207
AppProps = # 'v1_0.application_properties' {content = []},
210
- RespPayload = undefined ,
208
+ RespPayload = null ,
211
209
{Props , AppProps , RespPayload };
212
210
213
211
handle_http_req (<<" GET" >>,
214
212
[<<" bindings" >>],
215
213
QueryMap = #{<<" src" >> := SrcXNameBin ,
216
214
<<" key" >> := Key },
217
- [ undefined ] ,
215
+ null ,
218
216
Vhost ,
219
217
_User ,
220
218
_ConnPid ) ->
@@ -320,8 +318,8 @@ decode_req([], Acc) ->
320
318
Acc ;
321
319
decode_req ([# 'v1_0.properties' {} = P | Rem ], Acc ) ->
322
320
decode_req (Rem , setelement (1 , Acc , P ));
323
- decode_req ([# 'v1_0.amqp_value' {content = { binary , B } } | Rem ], Acc ) ->
324
- decode_req (Rem , setelement (2 , Acc , B ));
321
+ decode_req ([# 'v1_0.amqp_value' {content = C } | Rem ], Acc ) ->
322
+ decode_req (Rem , setelement (2 , Acc , C ));
325
323
decode_req ([_IgnoreSection | Rem ], Acc ) ->
326
324
decode_req (Rem , Acc ).
327
325
0 commit comments