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
bb55ceda
authored
Jun 19, 2017
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
support 'assumeContentBinary' flag
parent
77115c56
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
6 deletions
README.md
build.gradle
src/main/java/http/simpleHttpClient/SimpleHttpClient.java
src/main/java/http/simpleHttpClient/SimpleHttpResponse.java
README.md
View file @
bb55ceda
...
...
@@ -6,4 +6,6 @@
-
Handle correctly Exceptions in http requsts/responses
-
support Encoding type (other than utf8) in http responses
## 1.2.4
-
support binary content in response
\ No newline at end of file
-
support binary content in response
## 1.2.5
-
support 'assumeContentBinary' flag
\ No newline at end of file
build.gradle
View file @
bb55ceda
group
'com.ipgallery.common'
version
'1.2.
4
'
version
'1.2.
5
'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
...
...
src/main/java/http/simpleHttpClient/SimpleHttpClient.java
View file @
bb55ceda
...
...
@@ -30,6 +30,7 @@ public class SimpleHttpClient {
private
ThreadSafeClientConnManager
connManager
=
null
;
private
CookieStore
cookieStore
=
null
;
private
Map
<
String
,
Boolean
>
binaryMimeTypes
=
new
HashMap
<
String
,
Boolean
>();
private
Boolean
isAssumeBinaryContent
=
false
;
public
SimpleHttpClient
()
...
...
@@ -50,6 +51,11 @@ public class SimpleHttpClient {
this
.
defaulthttpClient
=
new
DefaultHttpClient
(
connManager
);
this
.
cookieStore
=
defaulthttpClient
.
getCookieStore
();
}
public
void
assumeBinaryContent
()
{
isAssumeBinaryContent
=
true
;
}
public
Boolean
isAssumeBinaryContent
()
{
return
isAssumeBinaryContent
;
}
public
void
shutdown
()
throws
Throwable
{
...
...
@@ -108,7 +114,11 @@ public class SimpleHttpClient {
try
{
HttpEntity
httpEntity
=
response
.
getEntity
();
if
(
httpEntity
!=
null
)
{
if
(
isContentBinary
(
response
))
{
if
(
isAssumeBinaryContent
)
{
InputStream
is
=
httpEntity
.
getContent
();
resp
.
binaryContent
=
IOUtils
.
toByteArray
(
is
);
}
else
if
(
isContentBinary
(
response
))
{
// content is binary
InputStream
is
=
httpEntity
.
getContent
();
byte
[]
baContent
=
IOUtils
.
toByteArray
(
is
);
...
...
src/main/java/http/simpleHttpClient/SimpleHttpResponse.java
View file @
bb55ceda
...
...
@@ -9,8 +9,8 @@ public class SimpleHttpResponse {
protected
int
statusCode
=
0
;
protected
Map
<
String
,
String
>
headers
;
protected
List
<
Cookie
>
cookies
;
protected
String
content
=
null
;
protected
String
content
=
null
;
protected
byte
[]
binaryContent
=
null
;
public
SimpleHttpResponse
()
{
}
...
...
@@ -27,6 +27,8 @@ public class SimpleHttpResponse {
public
void
setHeaders
(
Map
<
String
,
String
>
headers
)
{
this
.
headers
=
headers
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
byte
[]
getBinaryContent
()
{
return
binaryContent
;
}
public
void
setBinaryContent
(
byte
[]
binaryContent
)
{
this
.
binaryContent
=
binaryContent
;
}
@Override
public
String
toString
()
{
...
...
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