@@ -49,16 +49,9 @@ impl SendAccessClient {
49
49
. identity
50
50
. client
51
51
. post ( & url)
52
- . header (
53
- reqwest:: header:: CONTENT_TYPE ,
54
- "application/x-www-form-urlencoded; charset=utf-8" ,
55
- )
56
52
. header ( reqwest:: header:: ACCEPT , "application/json" )
57
53
. header ( reqwest:: header:: CACHE_CONTROL , "no-store" )
58
- // We can use `serde_urlencoded` to serialize the payload into a URL-encoded string
59
- // because we don't have complex nested structures in the payload.
60
- // If we had nested structures, we have to use serde_qs::to_string instead.
61
- . body ( serde_urlencoded:: to_string ( & payload) . expect ( "Serialize should be infallible" ) ) ;
54
+ . form ( & payload) ;
62
55
63
56
// Because of the ? operator, any errors from sending the request are automatically
64
57
// wrapped in SendAccessTokenError::Unexpected as an UnexpectedIdentityError::Reqwest
@@ -164,7 +157,7 @@ mod tests {
164
157
// expect the headers we set in the client
165
158
. and ( matchers:: header (
166
159
reqwest:: header:: CONTENT_TYPE . as_str ( ) ,
167
- "application/x-www-form-urlencoded; charset=utf-8 " ,
160
+ "application/x-www-form-urlencoded" ,
168
161
) )
169
162
. and ( matchers:: header (
170
163
reqwest:: header:: ACCEPT . as_str ( ) ,
@@ -234,7 +227,7 @@ mod tests {
234
227
// expect the headers we set in the client
235
228
. and ( matchers:: header (
236
229
reqwest:: header:: CONTENT_TYPE . as_str ( ) ,
237
- "application/x-www-form-urlencoded; charset=utf-8 " ,
230
+ "application/x-www-form-urlencoded" ,
238
231
) )
239
232
. and ( matchers:: header (
240
233
reqwest:: header:: ACCEPT . as_str ( ) ,
@@ -298,8 +291,6 @@ mod tests {
298
291
otp : otp. into ( ) ,
299
292
} ;
300
293
301
- let email_param = serde_urlencoded:: to_string ( [ ( "email" , email) ] ) . unwrap ( ) ; // "email=valid%40email.com"
302
-
303
294
let req = SendAccessTokenRequest {
304
295
send_id : "valid-send-id" . into ( ) ,
305
296
send_access_credentials : Some ( SendAccessCredentials :: EmailOtp (
@@ -312,7 +303,7 @@ mod tests {
312
303
// expect the headers we set in the client
313
304
. and ( matchers:: header (
314
305
reqwest:: header:: CONTENT_TYPE . as_str ( ) ,
315
- "application/x-www-form-urlencoded; charset=utf-8 " ,
306
+ "application/x-www-form-urlencoded" ,
316
307
) )
317
308
. and ( matchers:: header (
318
309
reqwest:: header:: ACCEPT . as_str ( ) ,
@@ -330,7 +321,7 @@ mod tests {
330
321
) ) )
331
322
. and ( body_string_contains ( format ! ( "scope={}" , scope_str) ) )
332
323
. and ( body_string_contains ( format ! ( "send_id={}" , req. send_id) ) )
333
- . and ( body_string_contains ( email_param ) )
324
+ . and ( body_string_contains ( "email=valid%40email.com" ) )
334
325
. and ( body_string_contains ( format ! ( "otp={}" , otp) ) )
335
326
// respond with the mock success response
336
327
. respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( raw_success) ) ;
0 commit comments