You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Vasiliy Keretsman <vk...@e-mobilink.com> on 2004/10/27 17:22:10 UTC
problem with posting cyrillic characters
hi there!
I have got a problem with posting cyrillic character using
http-client-2.0.2.
I receive somethig like "???? ?? ????" on server-side.
Could anyone help me?
Thank you.
here is bit of code :
-----------------------
try {
NameValuePair[] form_data = {new NameValuePair("param", "Тестовая строка")};
requestMethod.setRequestBody(form_data);
DefaultMethodRetryHandler retryhandler = new DefaultMethodRetryHandler();
retryhandler.setRequestSentRetryEnabled(false);
retryhandler.setRetryCount(3);
requestMethod.setMethodRetryHandler(retryhandler);
// Execute the method.
int statusCode = client.executeMethod(requestMethod);
System.out.println("STATUS CODE:"+ statusCode);
System.out.println("STATUS LINE:"+ requestMethod.getStatusLine());
if (statusCode == HttpStatus.SC_OK) {
System.out.println("Response Body:\n---\n" + requestMethod.getResponseBodyAsString());
}
}catch(Exception e){
e.printStackTrace();
} finally {
// Release the connection.
requestMethod.releaseConnection();
}
--
Best regards,
Vasiliy mailto:vk@e-mobilink.com
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: problem with posting cyrillic characters
Posted by Oleg Kalnichevski <ol...@apache.org>.
Privet, Vasiliy
This is a fairly common problem. Make sure that you set the correct
charset attribute in the 'Content-Type' header. This should pretty much
do the trick
requestMethod.setRequestHeader(
"Content-Type",
"application/x-www-form-urlencoded; charset=KOI8-R");
For more details please refer to the HttpClient character encoding
guide:
http://jakarta.apache.org/commons/httpclient/charencodings.html
Cheers,
Oleg
On Wed, Oct 27, 2004 at 06:22:10PM +0300, Vasiliy Keretsman wrote:
> hi there!
>
> I have got a problem with posting cyrillic character using
> http-client-2.0.2.
>
> I receive somethig like "???? ?? ????" on server-side.
>
> Could anyone help me?
>
> Thank you.
>
> here is bit of code :
> -----------------------
>
> try {
> NameValuePair[] form_data = {new NameValuePair("param", "???????? ??????")};
> requestMethod.setRequestBody(form_data);
>
> DefaultMethodRetryHandler retryhandler = new DefaultMethodRetryHandler();
> retryhandler.setRequestSentRetryEnabled(false);
> retryhandler.setRetryCount(3);
> requestMethod.setMethodRetryHandler(retryhandler);
>
> // Execute the method.
> int statusCode = client.executeMethod(requestMethod);
>
> System.out.println("STATUS CODE:"+ statusCode);
> System.out.println("STATUS LINE:"+ requestMethod.getStatusLine());
> if (statusCode == HttpStatus.SC_OK) {
> System.out.println("Response Body:\n---\n" + requestMethod.getResponseBodyAsString());
> }
> }catch(Exception e){
> e.printStackTrace();
> } finally {
> // Release the connection.
> requestMethod.releaseConnection();
> }
>
>
>
>
>
>
>
>
>
>
> --
> Best regards,
> Vasiliy mailto:vk@e-mobilink.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org