Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Aramayis
2021-04-06 12:13:56 +0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2021-04-06 12:13:56 +0400
Commit
5c5f202c7bfdf9867c1f53de3feb42e32dfd716b
5c5f202c
1 parent
039a9e73
Construct request with body for form-urlencoded.
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
lib/get_connect/http/src/http.dart
lib/get_connect/http/src/http.dart
View file @
5c5f202
...
...
@@ -103,18 +103,20 @@ class GetHttpClient {
headers
[
'content-length'
]
=
bodyBytes
.
length
.
toString
();
headers
[
'content-type'
]
=
'multipart/form-data; boundary=
${body.boundary}
'
;
}
else
if
(
contentType
!=
null
&&
contentType
.
toLowerCase
()
==
'application/x-www-form-urlencoded'
&&
body
is
Map
)
{
var
parts
=
[];
(
body
as
Map
<
String
,
dynamic
>).
forEach
((
key
,
value
)
{
parts
.
add
(
'
${Uri.encodeQueryComponent(key)}
='
'
${Uri.encodeQueryComponent(value.toString())}
'
);
});
var
formData
=
parts
.
join
(
'&'
);
bodyBytes
=
utf8
.
encode
(
formData
);
}
else
if
(
body
is
Map
||
body
is
List
)
{
var
jsonString
=
json
.
encode
(
body
);
bodyBytes
=
utf8
.
encode
(
jsonString
);
headers
[
'content-length'
]
=
bodyBytes
.
length
.
toString
();
headers
[
'content-type'
]
=
contentType
??
defaultContentType
;
//TODO check this implementation
if
(
contentType
!=
null
)
{
if
(
contentType
.
toLowerCase
()
==
'application/x-www-form-urlencoded'
)
{
jsonString
=
Uri
.
encodeQueryComponent
(
jsonString
);
}
}
}
else
if
(
body
is
String
)
{
bodyBytes
=
utf8
.
encode
(
body
);
headers
[
'content-length'
]
=
bodyBytes
.
length
.
toString
();
...
...
Please
register
or
login
to post a comment