﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc	parents
5397	API client registration fails if Content-Type has options	Ben Sturmfels		"I was just playing with the client registration API and noticed that the following valid request fails. The client I'm using is from the httpie package.

{{{
http --form --verbose POST http://127.0.0.1:6543/api/client/register type=client_associate application_type=native
POST /api/client/register HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Content-Length: 45
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: 127.0.0.1:6543
User-Agent: HTTPie/0.8.0

type=client_associate&application_type=native

HTTP/1.0 400 BAD REQUEST
Access-Control-Allow-Headers: Content-Type, X-Requested-With
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Origin: *
Content-Length: 33
Content-Type: application/json
Date: Tue, 19 Jan 2016 12:31:30 GMT
Server: PasteWSGIServer/0.5 Python/2.7.6
Set-Cookie: mediagoblin_csrftoken=12864927827420732302; HttpOnly; Path=
Vary: Cookie

{
    ""error"": ""Unknown Content-Type""
}
}}}

It should succeed like this:


{{{
HTTP/1.0 200 OK
Access-Control-Allow-Headers: Content-Type, X-Requested-With
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Origin: *
Content-Length: 120
Content-Type: application/json
Date: Tue, 19 Jan 2016 12:32:00 GMT
Server: PasteWSGIServer/0.5 Python/2.7.6
Set-Cookie: mediagoblin_csrftoken=726380659778734454; HttpOnly; Path=
Vary: Cookie

{
    ""client_id"": ""F5lY7pUrmL9ytOjF3RW1md"", 
    ""client_secret"": ""yAce42AR3a8SGUSiJDp4GbEaYB8xBQoktNU5ZjlpmWO"", 
    ""expires_at"": 0
}
}}}

This looks to be caused by the content-type parsing function not being aware of extra options like `Content-Type: application/x-www-form-urlencoded; charset=utf-8`, since the simpler case works `Content-Type: application/x-www-form-urlencoded`.

Attaching a patch including tests for the current code paths plus one with header options."	defect	closed	minor	0.9.0	programming	fixed			
