Mailman REST server reports bad HTTP request with code 200
When a call to the REST server is done with an invalid URL, the error message returned by Mailman is done with an HTTP code 200. As a consequence, the mailmanclient library interprets it as a valid reply and tries to JSON-decode it, which fails.
Example:
$ curl -i -u restadmin:restpass "http://localhost:8001/3.0/lists/list <there is a space here> example.com"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Error response</title>
</head>
<body>
<h1>Error response</h1>
<p>Error code: 400</p>
<p>Message: Bad request syntax ('GET /3.0/lists/list example.com HTTP/1.1').</p>
<p>Error code explanation: 400 - Bad request syntax or unsupported method.</p>
</body>
</html>
As you can see, I used the -i
option in curl which prints all response headers. Here, there are none, so the response is supposed valid (code 200).
In the log I get those two lines:
Oct 03 16:58:04 2016 (26467) 127.0.0.1 - - code 400, message Bad request syntax ('GET /3.0/lists/list example.com HTTP/1.1')
Oct 03 16:58:04 2016 (26467) 127.0.0.1 - - "GET /3.0/lists/list example.com HTTP/1.1" 400 -
This is extremely easy to reproduce, just use the curl command above.