hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Trouble with post in HttpClient 4.0.3
Date Tue, 26 Oct 2010 12:39:07 GMT
On Tue, 2010-10-26 at 04:57 -0700, Andre Brito wrote:
> Hey guys.
> We have 2 peace of software that imports a few data from sites. I was using
> HttpClient 3.1 and it was great! But then, one of the sites started to
> complain (maybe because of our access, I don't know) and was throwing
> exceptions about the certificate.
> 
> So I decided to change from 3.1 to 4.0.3. Ok, I can do the GET methods, but
> I can't build the POST. I'm getting a 417 HttpStatus code (expectation
> failed). In HttpClient 3.1, I was building the POST like this:
> 
> PostMethod method = new
> PostMethod("http://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/valida.asp");
> 
> method.addParameter("origem", "comprovante");
> method.addParameter("cnpj", cnpj);
> method.addParameter("idLetra", captcha);
> method.addParameter("idSom", "");
> method.addParameter("submit1", "Consultar");
> method.addParameter("search_type", "cnpj");
> method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new
> DefaultHttpMethodRetryHandler(3, false));
> 
> In HttpClient I'm doing like this:
> 
> HttpPost post = new HttpPost(url);
> 
> List<NameValuePair> parameters = new ArrayList<NameValuePair>();
> parameters.add(new BasicNameValuePair("origem", "comprovante"));
> parameters.add(new BasicNameValuePair("cnpj", cnpj));
> parameters.add(new BasicNameValuePair("idLetra", captcha));
> parameters.add(new BasicNameValuePair("idSom", ""));
> parameters.add(new BasicNameValuePair("submit1", "Consultar"));
> parameters.add(new BasicNameValuePair("search_type", "cnpj"));
> 
> post.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
> 
> Is that correct? If that so, I can't find a reason why in 3.1 is working and
> in 4.0.3 is not.
> 
> Can anyone give me a direction?

Try disabling the 'expect: continue' handshaking. 

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message