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: Using httpclient object: local vs object scope
Date Wed, 11 Jun 2008 12:31:44 GMT
On Wed, 2008-06-11 at 11:23 +0300, Vasilij Savin wrote:
> Greetings,
> 
> I have been playing with HttpClient 4 lately. It is pretty nice piece of 
> software, but recently I run into problem I was not able to resolve.
> 
> Currently I am using HttpClient to provide communication between sistem I 
> am developing and some external one, which uses webservices with XML 
> responses.
> 
> After studying examples of HC - I decided to use DefaultHttpClient 
> httpclient = new DefaultHttpClient(); as field and reuse for consequent 
> requests to external system.
> 
> 1st request works fine, but all the following requests fail with 
> exception:
> 
> org.apache.http.ProtocolException: Content-Length header already present
>         at org.apache.http.protocol.RequestContent.process(
> RequestContent.java:70)
>         at org.apache.http.protocol.BasicHttpProcessor.process(
> BasicHttpProcessor.java:290)
>         at org.apache.http.protocol.HttpRequestExecutor.preProcess(
> HttpRequestExecutor.java:160)
>         at 
> org.apache.http.impl.client.DefaultClientRequestDirector.execute(
> DefaultClientRequestDirector.java:356)
>         at org.apache.http.impl.client.AbstractHttpClient.execute(
> AbstractHttpClient.java:501)
>         at org.apache.http.impl.client.AbstractHttpClient.execute(
> AbstractHttpClient.java:456)
>         at org.apache.http.impl.client.AbstractHttpClient.execute(
> AbstractHttpClient.java:422)
>         at 
> lt.sintagma.ss5.core.documentImporter.AvilysAccessor.sendRequest(
> AvilysAccessor.java:80)
>         at 
> lt.sintagma.ss5.core.documentImporter.AvilysAccessor.getDocumentList(
> AvilysAccessor.java:151)
>         at lt.sintagma.ss5.core.AvilysIntegrationTest.testGetDocument(
> AvilysIntegrationTest.java:109)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.junit.internal.runners.TestMethodRunner.executeMethodBody(
> TestMethodRunner.java:99)
>         at org.junit.internal.runners.TestMethodRunner.runUnprotected(
> TestMethodRunner.java:81)
>         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(
> BeforeAndAfterRunner.java:34)
>         at org.junit.internal.runners.TestMethodRunner.runMethod(
> TestMethodRunner.java:75)
>         at org.junit.internal.runners.TestMethodRunner.run(
> TestMethodRunner.java:45)
>         at 
> org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(
> TestClassMethodsRunner.java:66)
>         at org.junit.internal.runners.TestClassMethodsRunner.run(
> TestClassMethodsRunner.java:35)
>         at org.junit.internal.runners.TestClassRunner$1.runUnprotected(
> TestClassRunner.java:42)
>         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(
> BeforeAndAfterRunner.java:34)
>         at org.junit.internal.runners.TestClassRunner.run(
> TestClassRunner.java:52)
>         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(
> JUnit4TestReference.java:38)
>         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(
> TestExecution.java:38)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> RemoteTestRunner.java:460)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> RemoteTestRunner.java:673)
>         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
> RemoteTestRunner.java:386)
>         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> RemoteTestRunner.java:196)
> 
> However, if I make httpclient as local variable - it works totally fine. 
> Can someone explain, what am I doing wrong in the first place. I have a 
> feeling that something is not cleared after the first request. But I can 
> not figure out what specifically.
> 

Vasilij,

Which version of HttpClient are you using? Please consider upgrading the
the latest SVN snapshot as there has been a number of important bug
fixes since the latest official release (4.0-alpha4).

Oleg  


> Vasilij Savin
> Programuotojas / Programmer
> Dokumentų ir procesų valdymo projektų skyrius
> 
> UAB "Sintagma"
> Kalvarijų 125, LT-08221 Vilnius
> vasilij.savin@sintagma.lt
> www.sintagma.lt


---------------------------------------------------------------------
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