Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CTF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grzegorz
CTF
Commits
7f0c0cff
Commit
7f0c0cff
authored
Feb 20, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enhance proxy resource
parent
bd7b5a7e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
ProxyResource.java
service/src/main/java/api/ProxyResource.java
+6
-3
No files found.
service/src/main/java/api/ProxyResource.java
View file @
7f0c0cff
...
@@ -8,6 +8,7 @@ import org.apache.http.impl.client.HttpClients;
...
@@ -8,6 +8,7 @@ import org.apache.http.impl.client.HttpClients;
import
javax.ws.rs.GET
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -16,15 +17,17 @@ import java.io.InputStream;
...
@@ -16,15 +17,17 @@ import java.io.InputStream;
/**
/**
* Created by gpietrus on 16.02.16.
* Created by gpietrus on 16.02.16.
*/
*/
@Path
(
value
=
"/proxy"
)
@Path
(
value
=
"/proxy
/task
"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
class
ProxyResource
public
class
ProxyResource
{
{
@GET
@GET
@Path
(
"{task_id}/{path: .*}"
)
@Produces
(
"text/html; charset=UTF-8"
)
@Produces
(
"text/html; charset=UTF-8"
)
public
InputStream
foo
()
throws
IOException
{
public
InputStream
foo
(
final
@PathParam
(
"task_id"
)
String
taskId
,
final
@PathParam
(
"path"
)
String
path
)
throws
IOException
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
HttpGet
httpget
=
new
HttpGet
(
"http
://onet.pl"
);
HttpGet
httpget
=
new
HttpGet
(
"http
s://pl.wikipedia.org/"
+
taskId
+
"/"
+
path
);
CloseableHttpResponse
execute
=
httpClient
.
execute
(
httpget
);
CloseableHttpResponse
execute
=
httpClient
.
execute
(
httpget
);
HttpEntity
entity
=
execute
.
getEntity
();
HttpEntity
entity
=
execute
.
getEntity
();
return
entity
.
getContent
();
return
entity
.
getContent
();
...
...
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