#36 POST parameters ignored in AJAX requests

open
nobody
None
5
2012-09-14
2009-02-16
Anonymous
No

net.aserve:request-query will ignore POST parameters if content-type is not equal to "application/x-www-form-urlencoded".

But if I set content-type on client [Firefox 3.0.6 using XMLHttpRequest()] with something like

http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

the server will receive content-type = "application/x-www-form-urlencoded; charset=UTF-8".

To fix this quickly I replaced, in the definition of net.aserve:request-query, the test

(equal (header-slot-value req :content-type) "application/x-www-form-urlencoded")

by

(application/x-www-form-urlencoded? req)

where application/x-www-form-urlencoded? is defined as follows

(defun application/x-www-form-urlencoded? (req)
(let ((pos
(mismatch
(header-slot-value req :content-type)
"application/x-www-form-urlencoded"
:test #'char-equal)))
(or
(null pos)
(= pos #.(length "application/x-www-form-urlencoded")))))

Discussion

  • I just found and fixed the exact same bug.

    Is anybody maintaining this system? Does not seem very active.