Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.java
/
utils
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
66d4ed7b
authored
Aug 01, 2019
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
support query parameter without name=
parent
06c5b9ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
build.gradle
src/main/java/http/simpleHttpClient/SimpleHttpRequest.java
build.gradle
View file @
66d4ed7b
group
'com.ipgallery.common'
version
'1.
2.6
'
version
'1.
3.1
'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
...
...
src/main/java/http/simpleHttpClient/SimpleHttpRequest.java
View file @
66d4ed7b
...
...
@@ -99,30 +99,40 @@ public class SimpleHttpRequest {
this
.
queryString
=
""
;
}
public
void
addQueryStringParam
(
String
name
,
String
value
)
{
String
escName
=
pes
.
escape
(
name
);
// escape name
String
escName
=
null
;
if
(
name
!=
null
&&
name
.
isEmpty
()
==
false
)
escName
=
pes
.
escape
(
name
);
// escape value
String
escValue
=
pes
.
escape
(
value
);
// add to query string
if
(!
queryString
.
equals
(
""
))
queryString
+=
"&"
;
queryString
+=
escName
+
"="
+
escValue
;
if
(
escName
!=
null
)
queryString
+=
escName
+
"="
+
escValue
;
else
queryString
+=
escValue
;
}
private
String
EscapeQueryString
(
String
queryString
)
{
StringBuilder
sb
=
new
StringBuilder
();
String
[]
param
Token
s
=
queryString
.
split
(
"&"
);
if
(
param
Token
s
!=
null
)
{
for
(
String
param:
param
Token
s
)
{
String
[]
params
=
queryString
.
split
(
"&"
);
if
(
params
!=
null
)
{
for
(
String
param:
params
)
{
// split the param into name and value
String
[]
fieldTokens
=
new
String
[
2
];
//
String[] fieldTokens = new String[2];
int
equalPos
=
param
.
indexOf
(
'='
);
if
(
equalPos
>
0
)
{
fieldTokens
[
0
]
=
param
.
substring
(
0
,
equalPos
);
fieldTokens
[
1
]
=
param
.
substring
(
equalPos
+
1
);
if
(
fieldTokens
!=
null
&&
fieldTokens
.
length
==
2
)
{
String
field
=
pes
.
escape
(
fieldTokens
[
0
])
+
"="
+
pes
.
escape
(
fieldTokens
[
1
]);
if
(
sb
.
length
()
>
0
)
sb
.
append
(
"&"
);
sb
.
append
(
field
);
}
String
name
=
param
.
substring
(
0
,
equalPos
);
String
value
=
param
.
substring
(
equalPos
+
1
);
String
escapedParam
=
pes
.
escape
(
name
)
+
"="
+
pes
.
escape
(
value
);
if
(
sb
.
length
()
>
0
)
sb
.
append
(
"&"
);
sb
.
append
(
escapedParam
);
}
else
sb
.
append
(
pes
.
escape
(
param
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment