Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"WebKitFormBoundary" when parsing POST using nodejs

Tags:

http

post

node.js

I've implemented a http server parsing POST with the help from http://blog.thekfactor.info/posts/an-introduction-to-node-js-and-handling-post-requests/ (simply I don't want use express.)

However, what I got has

[2013-10-10 10:27:29.670] [INFO] console - ------WebKitFormBoundaryMjfXHTTJYUdOInJ4 Content-Disposition: form-data; name="route"

connector.sgtrackHandler.log ------WebKitFormBoundaryMjfXHTTJYUdOInJ4 Content-Disposition: form-data; name="body"

{"appid":"1234","event":"test","params":{}} ------WebKitFormBoundaryMjfXHTTJYUdOInJ4--

[2013-10-10 10:27:29.671] [INFO] console - { '------ WebKitFormBoundaryMjfXHTTJYUdOInJ4\r\nContent-Disposition: form-data; name': '"route"\r\n\r\nconnector.sgtrackHandler.log\r\n------WebKitFormBoundaryMjfXHTTJYUdOInJ4\r\nContent-Disposition: form-data; name="body"\r\n\r\n{"appid":"1234","event":"test","params":{}}\r\n------WebKitFormBoundaryMjfXHTTJYUdOInJ4--\r\n' }

I cannot handle the such multipart form WebKitFormBoundaryMjfXHTTJYUdOInJ4...any idea?

like image 465
Kanglai Avatar asked Oct 10 '13 02:10

Kanglai


1 Answers

The code you're referring to parses application/x-www-form-urlencoded, whereas what's being posted is multipart/form-data, as defined in RFC2388.

To make it easier on yourself, you can use formidable (which Express also uses).

like image 108
robertklep Avatar answered Oct 31 '22 23:10

robertklep