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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
3 deletions
README.md
build.gradle
src/main/java/http/simpleHttpClient/SimpleHttpClient.java
src/main/java/http/simpleHttpClient/SimpleHttpResponse.java
README.md
View file @
bb55ceda
...
@@ -7,3 +7,5 @@
...
@@ -7,3 +7,5 @@
-
support Encoding type (other than utf8) in http responses
-
support Encoding type (other than utf8) in http responses
## 1.2.4
## 1.2.4
-
support binary content in response
-
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'
group
'com.ipgallery.common'
version
'1.2.
4
'
version
'1.2.
5
'
apply
plugin:
'java'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
apply
plugin:
'maven-publish'
...
...
src/main/java/http/simpleHttpClient/SimpleHttpClient.java
View file @
bb55ceda
...
@@ -30,6 +30,7 @@ public class SimpleHttpClient {
...
@@ -30,6 +30,7 @@ public class SimpleHttpClient {
private
ThreadSafeClientConnManager
connManager
=
null
;
private
ThreadSafeClientConnManager
connManager
=
null
;
private
CookieStore
cookieStore
=
null
;
private
CookieStore
cookieStore
=
null
;
private
Map
<
String
,
Boolean
>
binaryMimeTypes
=
new
HashMap
<
String
,
Boolean
>();
private
Map
<
String
,
Boolean
>
binaryMimeTypes
=
new
HashMap
<
String
,
Boolean
>();
private
Boolean
isAssumeBinaryContent
=
false
;
public
SimpleHttpClient
()
public
SimpleHttpClient
()
...
@@ -51,6 +52,11 @@ public class SimpleHttpClient {
...
@@ -51,6 +52,11 @@ public class SimpleHttpClient {
this
.
cookieStore
=
defaulthttpClient
.
getCookieStore
();
this
.
cookieStore
=
defaulthttpClient
.
getCookieStore
();
}
}
public
void
assumeBinaryContent
()
{
isAssumeBinaryContent
=
true
;
}
public
Boolean
isAssumeBinaryContent
()
{
return
isAssumeBinaryContent
;
}
public
void
shutdown
()
throws
Throwable
public
void
shutdown
()
throws
Throwable
{
{
defaulthttpClient
.
getConnectionManager
().
shutdown
();
defaulthttpClient
.
getConnectionManager
().
shutdown
();
...
@@ -108,7 +114,11 @@ public class SimpleHttpClient {
...
@@ -108,7 +114,11 @@ public class SimpleHttpClient {
try
{
try
{
HttpEntity
httpEntity
=
response
.
getEntity
();
HttpEntity
httpEntity
=
response
.
getEntity
();
if
(
httpEntity
!=
null
)
{
if
(
httpEntity
!=
null
)
{
if
(
isContentBinary
(
response
))
{
if
(
isAssumeBinaryContent
)
{
InputStream
is
=
httpEntity
.
getContent
();
resp
.
binaryContent
=
IOUtils
.
toByteArray
(
is
);
}
else
if
(
isContentBinary
(
response
))
{
// content is binary
// content is binary
InputStream
is
=
httpEntity
.
getContent
();
InputStream
is
=
httpEntity
.
getContent
();
byte
[]
baContent
=
IOUtils
.
toByteArray
(
is
);
byte
[]
baContent
=
IOUtils
.
toByteArray
(
is
);
...
...
src/main/java/http/simpleHttpClient/SimpleHttpResponse.java
View file @
bb55ceda
...
@@ -9,8 +9,8 @@ public class SimpleHttpResponse {
...
@@ -9,8 +9,8 @@ public class SimpleHttpResponse {
protected
int
statusCode
=
0
;
protected
int
statusCode
=
0
;
protected
Map
<
String
,
String
>
headers
;
protected
Map
<
String
,
String
>
headers
;
protected
List
<
Cookie
>
cookies
;
protected
List
<
Cookie
>
cookies
;
protected
String
content
=
null
;
protected
String
content
=
null
;
protected
byte
[]
binaryContent
=
null
;
public
SimpleHttpResponse
()
{
public
SimpleHttpResponse
()
{
}
}
...
@@ -27,6 +27,8 @@ public class SimpleHttpResponse {
...
@@ -27,6 +27,8 @@ public class SimpleHttpResponse {
public
void
setHeaders
(
Map
<
String
,
String
>
headers
)
{
this
.
headers
=
headers
;
}
public
void
setHeaders
(
Map
<
String
,
String
>
headers
)
{
this
.
headers
=
headers
;
}
public
String
getContent
()
{
return
content
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
byte
[]
getBinaryContent
()
{
return
binaryContent
;
}
public
void
setBinaryContent
(
byte
[]
binaryContent
)
{
this
.
binaryContent
=
binaryContent
;
}
@Override
@Override
public
String
toString
()
{
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