Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 65783DAE9 for ; Thu, 25 Oct 2012 19:37:12 +0000 (UTC) Received: (qmail 82164 invoked by uid 500); 25 Oct 2012 19:37:12 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 82136 invoked by uid 500); 25 Oct 2012 19:37:12 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 82127 invoked by uid 99); 25 Oct 2012 19:37:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2012 19:37:12 +0000 Date: Thu, 25 Oct 2012 19:37:12 +0000 (UTC) From: "Oleg Kalnichevski (JIRA)" To: dev@hc.apache.org Message-ID: <1888505446.28994.1351193832189.JavaMail.jiratomcat@arcas> In-Reply-To: <1105900613.27617.1351175592509.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (HTTPCLIENT-1253) URIBuilder setParameter() method could exceed the http header size. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HTTPCLIENT-1253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13484412#comment-13484412 ] Oleg Kalnichevski commented on HTTPCLIENT-1253: ----------------------------------------------- Alan URIBuilder is completely HTTP message agnostic. I am not sure I understand what kind of change you are proposing. Oleg > URIBuilder setParameter() method could exceed the http header size. > --------------------------------------------------------------------- > > Key: HTTPCLIENT-1253 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1253 > Project: HttpComponents HttpClient > Issue Type: Improvement > Components: HttpClient > Affects Versions: 4.2.1 > Reporter: Alan T Chen > Priority: Minor > > Maybe the URIBuilder is not designed with POST vs GET in mind so it will construct the form parameters into the header by default. However, this is an issue when the content exceeds what the header allows. > the following code will cause issues when the length of the parameters exceed the http header. > // TODO: need to pass in the target host/port > URIBuilder builder = new URIBuilder(); > builder.setScheme("http").setHost(targetHost).setPort(targetPort).setPath(s); > Map params = getRequestParameters(servletRequest); > for (String key : params.keySet()) > { > String value = params.get(key); > builder.setParameter(key, value); > } > httpPost = new HttpPost(builder.build()); > ======== > I have to fix it by using the httpPost.setEntity() method to ensure the form post will insert all parameters into the body of the http post request instead of the header. > httpPost = new HttpPost(builder.build()); > Map params = getRequestParameters(servletRequest); > List nameValuePairs = new ArrayList(20); > // add the params > for (String key : params.keySet()) > { > String value = params.get(key); > // only add the http param if both key and value are not null > if( key != null && value != null ) > nameValuePairs.add(new BasicNameValuePair(key, value)); > } > httpPost.setEntity( new UrlEncodedFormEntity(nameValuePairs) ); -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org