Skip to content

MockHttpServletResponse.setIntHeader throws exception for 'Content-Length' header [SPR-13752] #18325

@spring-projects-issues

Description

@spring-projects-issues

Dmitry Bedrin opened SPR-13752 and commented

MockHttpServletResponse.setIntHeader("Content-Length", 42) throws an Exception due to a bug in following code:

private boolean setSpecialHeader(String name, Object value) {
     if (CONTENT_TYPE_HEADER.equalsIgnoreCase(name)) {
          setContentType((String) value);
          return true;
     }
     else if (CONTENT_LENGTH_HEADER.equalsIgnoreCase(name)) {
          setContentLength(Integer.parseInt((String) value));
          return true;
     }
     else {
          return false;
     }
}

Affects: 4.1.8, 4.2.3

Issue Links:

Referenced from: pull request #929, and commits a4f5c46, 79ded1c

Backported to: 4.1.9

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions