Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom headers and 301 #414

Open
jocelynduc opened this issue Jul 5, 2018 · 0 comments
Open

Custom headers and 301 #414

jocelynduc opened this issue Jul 5, 2018 · 0 comments

Comments

@jocelynduc
Copy link

Hello,

I am trying to use LittleProxy as a reverse proxy by modifying httpObjects in a HttpFiltersSourceAdapter.

My backend server does need some custom headers (let's say customheader1 and customheader2) to handle/authorize properly my requests (own business rule). If I do not send those headers, backend returns a 403.

So, I add my custom headers like that:

@Override
public HttpResponse proxyToServerRequest(HttpObject httpObject) {
    if (httpObject instanceof HttpRequest) {
        HttpRequest httpRequest = (HttpRequest) httpObject;
        HttpHeaders headers = httpRequest.headers();

        headers.add("customheader1", "customcontent1" )
        headers.add("customheader2", "customcontent2" )

        LOGGER.info("proxyToServerRequest " + httpObject);
    }
    return super.proxyToServerRequest(httpObject);
}

The logger shows me the expected HTTP request and the backend server receives the headers in a correct way. Here is what the backend access.log tells me:

Method URI Code Referer Headers
GET /app 302 http://localhost:8442 customheader1 customheader2
GET /app/ 301 http://localhost:8442/app/index.xhtml - -
GET /app/index.xhtml 403 http://backend:8084/app/ - -

Observations:

  • First request is received with my headers
  • Second and third requests contains no header.
  • The Postman client trigger the request once and, behind, the backend server receive those three request.
  • As said and as the backend server receive a request without headers, Postman get a 403 as final response

Question:

  • How can I insure that the second an third request are sent with the custom headers?

I am not an expert but I think that after receiving a 302, LittleProxy fires automatically the second request, isn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant