Posting HTTP Form Data with Erlang

Tim Fletcher <>
Wed Aug 18 14:06:42 CEST 2010


> httpc:request(post, {Url, [], "application/x-www-form-urlencoded, "key=value&key2=value2}, [], []).
>
> If required you could use edoc:escape_uri(String) for the individual values.

URI escaping and application/x-www-form-urlencoded escaping are not
exactly the same thing though.

There's an implementation of both here:

  http://github.com/tim/erlang-percent-encoding

I'd appreciate any feedback on the correctness of the code/tests.

> Yes, I discovered that shortly after sending the email; prompting me
> to write the following function, rather than take on an external
> dependency, which I'm a little loathed to do for something so small:

Agreed. I usually copy/paste bits into other projects, for example:

  http://github.com/tim/erlang-webfinger/blob/master/src/webfinger.erl#L65-82

Cheers,
Tim


More information about the erlang-questions mailing list