Skip to content

Commit

Permalink
only pass the X-Forwarded-Host header to traverson
Browse files Browse the repository at this point in the history
  • Loading branch information
spencergibb committed Nov 26, 2014
1 parent 44d93cb commit 6ac1028
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@
*/
package example.customers.integration;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import example.customers.Customer;
import example.customers.Location;
import lombok.RequiredArgsConstructor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceProcessor;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;

import example.customers.Customer;
import example.customers.Location;

import javax.inject.Provider;
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
* @author Oliver Gierke
Expand All @@ -42,7 +38,8 @@
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CustomerResourceProcessor implements ResourceProcessor<Resource<Customer>> {

private final StoreIntegration storeIntegration;
private static final String X_FORWARDED_HOST = "X-Forwarded-Host";
private final StoreIntegration storeIntegration;
private final Provider<HttpServletRequest> requestProvider;

@Override
Expand All @@ -53,9 +50,9 @@ public Resource<Customer> process(Resource<Customer> resource) {

HttpHeaders headers = new HttpHeaders();

for (String name : Collections.list(requestProvider.get().getHeaderNames())) {
ArrayList<String> values = Collections.list(requestProvider.get().getHeaders(name));
headers.put(name, values);
String header = requestProvider.get().getHeader(X_FORWARDED_HOST);
if (header != null) {
headers.put(X_FORWARDED_HOST, Collections.singletonList(header));
}

Map<String, Object> parameters = new HashMap<>();
Expand Down

0 comments on commit 6ac1028

Please sign in to comment.