Toggle navigation
Toggle navigation
This project
Loading...
Sign in
cse437_e
/
smartdoorlock-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
오윤석
2020-11-07 05:58:12 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a797f66bc37811380b4439a1d83110d3215840a9
a797f66b
1 parent
09c514ec
GET, DELETE method의 경우 querystring 추가
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
View file @
a797f66
...
...
@@ -17,6 +17,8 @@ import java.io.InputStreamReader;
import
java.io.OutputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.Iterator
;
import
java.util.Set
;
public
class
Api
{
public
interface
Callback
{
...
...
@@ -32,8 +34,18 @@ public class Api {
public
void
run
()
{
ApiResult
apiResult
;
try
{
Log
.
d
(
"test"
,
"callApi"
);
URL
url
=
new
URL
(
"http://"
+
Api
.
DOMAIN
+
endpoint
);
String
queryString
=
""
;
if
((
"GET"
.
equals
(
method
)
||
"DELETE"
.
equals
(
method
))
&&
params
!=
null
)
{
Set
<
String
>
keys
=
params
.
keySet
();
Iterator
<
String
>
iter
=
keys
.
iterator
();
while
(
iter
.
hasNext
())
{
String
key
=
iter
.
next
();
queryString
+=
"&"
+
key
+
"="
+
params
.
get
(
key
).
getAsString
();
}
queryString
=
"?"
+
queryString
.
substring
(
1
);
}
URL
url
=
new
URL
(
"http://"
+
Api
.
DOMAIN
+
endpoint
+
queryString
);
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setRequestMethod
(
method
);
...
...
Please
register
or
login
to post a comment