Hi folks,

 

i have a strange problem:

 

I use the http-client for data transmission between two servlets.

Before that i used HttpUrlConnection. With HttpUrlConnection i could transmit 
quite large files.

Now i completely converted my application to http-client.

The file transmission still works, but unfortunately only for a very small file 
size.

 

If i exceed this limited file size (just a few KB) i get the following apache 
error:

            

request failed: URI too long (longer than 8190)

 

Google now tells me, that this only happens using the "GET" method, because 
with GET the length of an URL is limited.

 

BUT:

 

I don't use the Get-method, instead i use the post method:

 

 Code:

 

   protected String sendRequest(String urlParams) {

 

      String answer = null;

   

      HttpClient httpClient = new HttpClient();

      

      if(networkParams.isUseProxy()) {

         
httpClient.getHostConfiguration().setProxy(networkParams.getProxyHost(), 
networkParams.getProxyPort());

         logger.info("we DO use a proxy: host:" + networkParams.getProxyHost() 
+ "Port: " + new Integer(networkParams.getProxyPort()).toString());

      }

      if(networkParams.isUseProxyCredentials()) {

         httpClient.getState().setProxyCredentials(

                     new AuthScope(networkParams.getProxyHost(), 
networkParams.getProxyPort()),

                     new 
UsernamePasswordCredentials(networkParams.getProxyUserName(), 
networkParams.getProxyUserPassword()));

      }

      

      String url = networkParams.getRemoteProtocoll() +

                 networkParams.getRemoteDestinationAdress() +

                 ":" +

                 networkParams.getRemoteDestinationPort() +

                 networkParams.getRemoteDestinationPath();

      

      HttpMethod method = new PostMethod(url);

      method.setQueryString(urlParams);

   

      try {

         int statusCode = httpClient.executeMethod(method);

         if (statusCode != HttpStatus.SC_OK) {

            logger.error(OutputConstants.ERR_WRONG_RESPONSE + 
CommonOutput.LOG_SPACER + statusCode);

            return null;

         }

         answer = method.getResponseBodyAsString();

      } catch (HttpException e) {

         logger.error(e.getMessage());

         logger.error(e);

         return null;

      } catch (IOException e) {

         logger.error(e.getMessage());

         logger.error(e);

         return null;

      }

      finally {   

         method.releaseConnection();

      }

      return answer;

   }

 

 

This code part should be the relevant one:

 

 Code:

            

HttpMethod method = new PostMethod(url);

 

I don't get it, everything seems to be fine as far as i can tell?

 

The Apache configuration can not be the problem, because i didn't change it and 
when i used HttpUrlConnection with "POST" the transfer of bigger files was no 
problem. This seems to an http-client problem?

 

Does anybody see whats going wrong here?

 

Beste Grüße / Best Regards,

 

Timo Rössner

 

Wincor Nixdorf International GmbH
Services Division OES
Timo Roessner
Wernerwerkdamm 5 (Gebäude 202 / 7.Flur / Raum 743)
13629 Berlin
Germany
Tel.:  +49 30  5017 2865
Fax.:  +49 30  5017 2872
Mobil:  +49 151 171 573 16
Mail:[EMAIL PROTECTED]

 

Reply via email to