How to specify charset of POST parameters?

7 views
Skip to first unread message

lasconic

unread,
Oct 30, 2009, 8:38:56 AM10/30/09
to SoundCloudAPI
I'm trying to send a description with unicode chars along with an ogg
file.
If I use
Content-Type: plain/text; charset=utf-8
for one of the form-data element I got Error 500.

What's the normal way to specify a charset?

Hannes Tydén

unread,
Nov 15, 2009, 12:44:01 PM11/15/09
to SoundCloudAPI
I've been trying to find a clear reproduction case for this problem,
but have not yet found one.

When investigating I've found that the Content-Length is the most
problem of failure, probably because linefeeds are counted as one
character, but they're sent as carriage return and linefeed, which
means an extra byte per line should be added to the content length.

All my failing requests have actually been "Bad Requests" with an
incorrect Content-Length, so the correct error response should be 400
Bad Request.

Good luck with your further programming endeavors,
Hannes

Stjepan Rajko

unread,
Nov 15, 2009, 1:22:30 PM11/15/09
to soundc...@googlegroups.com
On Sun, Nov 15, 2009 at 10:44 AM, Hannes Tydén <han...@soundcloud.com> wrote:

I've been trying to find a clear reproduction case for this problem,
but have not yet found one.


Hannes, I think this sounds like the problem I was experiencing in
http://groups.google.com/group/soundcloudapi/browse_thread/thread/d3ecf4011b04ac8f

In the end you and I found that putting a Content-Type / Content-Transfer-Encoding with a form-data parameter causes the Internal Server Error, while omitting them results in a successful request.

You can reproduce the problem by getting SoundCloud Droid running (see http://code.google.com/p/soundclouddroid/wiki/DeveloperGettingStarted), and then commenting out these lines at the bottom of SoundCloudRequest.java:

//    protected void sendContentTypeHeader(OutputStream arg0)
//    {
//    }

Best,

Stjepan



Hannes Tydén

unread,
Nov 17, 2009, 5:52:24 AM11/17/09
to soundc...@googlegroups.com
On Sun, Nov 15, 2009 at 7:22 PM, Stjepan Rajko <stjepa...@gmail.com> wrote:
> In the end you and I found that putting a Content-Type /
> Content-Transfer-Encoding with a form-data parameter causes the Internal
> Server Error, while omitting them results in a successful request.

Many thanks for your perseverance when debugging this. It is highly appreciated!

I actually managed to send all kinds of Content-Types and
Content-Transfer-Encodings successfully as long as I updated the
Content-Length header accordingly.

Cheers,
Hannes


--
Hannes Tydén
Developer, SoundCloud

Mail: han...@soundcloud.com
Skype: hannestyden
Phone: +49 157 7471 6101
Rosenthalerstr. 13
10119 Berlin, DE

What is SoundCloud?
http://soundcloud.com/tour

lasconic

unread,
Nov 21, 2009, 12:11:38 PM11/21/09
to SoundCloudAPI
Could you provide the description part of a working request with for
example russian characters in the description?
Using the following, russian chars are displayed as "square" or "?"
on Soundcloud.
content.append("-----------------------------"+boundary+"\r\n");
content.append("Content-Disposition: form-data; name=\"track
[description]\"\r\n\r\n");
content.append(description);
content.append("\r\n");

If I add "Content-Type: text/plain; charset=utf8\r\n"
I got the following description
--- !ruby/object:File
content_type: text/plain; charset=utf-8
original_path:

So wrong as well. A working dump would be very useful.








Reply all
Reply to author
Forward
0 new messages