Answer the question
In order to leave comments, you need to log in
Why can't fetch content with the Jersey Client when Nginx is enabled?
I am writing a link shortener. For some reason there shouldn't be a redirect, so I download the content from the link using the Jersey client and serve it to the user.
private Client client = ClientBuilder.newClient();
@GET
@Path("{code}")
public Response getContentLink(@PathParam("code") String code) {
return client
.target(shortUrlService.getCommonUrl(code)) //получение длинной ссылки из базы
.request(MediaType.TEXT_HTML)
.get();
}
Answer the question
In order to leave comments, you need to log in
In general, the problem was not in the nginx settings, but in the disposability (?) of the Response object. It is not clear why it worked on the test. Decided like this:
private Client client = ClientBuilder.newClient();
@GET
@Path("{code}")
public Response getContentLink(@PathParam("code") String code) {
Response response = client
.target(shortUrlService.getCommonUrl(code)) //получение длинной ссылки из базы
.request(MediaType.TEXT_HTML)
.get();
return Response
.status(response.getStatus())
.entity(response.getEntity())
.build();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question