HTTPRequest adds unnecessary line separator

Issue #81 resolved
Michael Mansell created an issue

When parsing the POST body, it always adds a line separator to the query, even if it's a single line body (See HTTPRequest line 230 ). This can cause some problems for downstream parsing.

My specific case was I was adding a scope to the TokenRequest, and the HTTPRequest query field ended up looking like (note the \r\n on the end; of course, it's not these characters, but a real line terminator).

grant_type=password&username=testuser&password=testpassword&scope=openid\r\n

even though it was all submitted as a single line without any line delimiter.

Unfortunately, when the TokenRequest is parsed, the value of the Scope became openid\r\n, and then, it wouldn't match when querying the Scope object, since the single key added to the set was openid\r\n

Comments (3)

  1. Gediminas Rimša

    Ran into the same issue. Workaround:

    HTTPRequest request = new HTTPRequest(req);
    request.setQuery(StringUtils.trim(request.getQuery()));
    
  2. Log in to comment