Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

Commit

Permalink
Strip the X- prefix from headers that we copy into the context attrib…
Browse files Browse the repository at this point in the history
…ute map. (#66)
  • Loading branch information
chirino authored and gastaldi committed Sep 22, 2017
1 parent 6096394 commit 9b336d2
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,15 @@ private RestUIContext createUIContext(Path initialPath, HttpHeaders headers)
{
Map<Object, Object> attributeMap = context.getAttributeMap();
MultivaluedMap<String, String> requestHeaders = headers.getRequestHeaders();
requestHeaders.keySet().forEach(key -> attributeMap.put(key, headers.getRequestHeader(key)));
requestHeaders.keySet().forEach(key -> attributeMap.put(stripPrefix(key, "X-"), headers.getRequestHeader(key)));
}
return context;
}

static private String stripPrefix(String value, String prefix) {
if( value.startsWith(prefix) ) {
return value.substring(prefix.length());
}
return value;
}
}

0 comments on commit 9b336d2

Please sign in to comment.