knutin / elli

Simple, robust and performant Erlang web server
MIT License
663 stars 79 forks source link

Can you help me with the "multipart/form-data" Content-Type #106

Closed sohailgerman closed 8 years ago

sohailgerman commented 8 years ago

I get this binary string in request and need to convert it to JSON Format

<<"--48940923NODERESLTER3890457293\r\nContent-Disposition: form-data; name=\"CallSid\"\r\n\r\n4025beb07e1faac824c6b2f9e22e0b5f\r\n--48940923NODERESLTER3890457293\r\nContent-Disposition: form-data; name=\"Status\"\r\n\r\nfailed\r\n--48940923NODERESLTER3890457293\r\nContent-Disposition: form-data; name=\"DateUpdated\"\r\n\r\n2016-11-07 16:01:40\r\n--48940923NODERESLTER3890457293--\r\n">>

wangyangkobe commented 8 years ago

I think your input is invalid json. see --48940923NODERESLTER3890457293, not key-value format.

sohailgerman commented 8 years ago

It is not JSON format it is in the form of multipart/form-data format which is received from post request from another server.

knutin commented 8 years ago

There's no built-in support for forms in Elli. As you see, it just gives you the body and it's up to you to make the decision of how to parse it.

Here's a library for parsing multipart forms: https://github.com/mme/erlmultipart I've never used this myself and don't know how complete it is, but maybe it's worth a shot.