Skip to content
Snippets Groups Projects

fix: correct handling of HttpServletRequest#getHeaders and tests

Merged Nicholas Blair requested to merge npblair/uw-spring-security:issue-6 into master

This pull request addresses issue #6.

Properly handles cases where container may return blank String values in the returned list. Tests were previously adding List objects as headers - need to add just String values.

See the javadocs for HttpServletRequest#getHeaders for reference.

I intend to release 1.6.1 when this is merged.

Edit: this also corrects the case of the name of the Manifest isMemberOf header.

cc: @paul.erickson @levett @bhill6

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
115 * This method provides a safe way to get the values for the specified header as a non-null
116 * (but still potentially empty) {@link List}.
117 *
118 * @see HttpServletRequest#getHeaders(String)
119 * @see StringUtils#isNotBlank(CharSequence)
120 * @param request the HTTP request
121 * @param headerName the name of the multi-valued header
122 * @return a never null, but potentially empty, {@link List} of not blank values for the requested header
123 */
124 protected List<String> safeGetHeaders(HttpServletRequest request, String headerName) {
125 Enumeration<String> enumeration = request.getHeaders(headerName);
126 if(enumeration == null) {
127 return Collections.emptyList();
128 }
129 List<String> result = new ArrayList<>();
130 for(String next : Collections.list(enumeration)){
  • Nicholas Blair Status changed to merged

    Status changed to merged

  • Nicholas Blair mentioned in commit fcd9cfd1

    mentioned in commit fcd9cfd1

  • Please register or sign in to reply
    Loading