Re: HTTPClient RC2 - Response content length is not known

2003-11-07 Thread Eric Johnson
Brad,

No worries about which list you subscribe to.  Many on this list are 
happy to answer questions such as yours.

HttpClient uses commons-logging for its configuration.  If you've 
configued commons-logging properly, the message can be made to go away 
as you indicated.  Since you already generated a wire log, presumably 
you've seen the page for configuring logging.  My suggestion would be to 
look at those instructions again, except change the logging level 
(debug, info, warn, error).  Where you see this:
System.setProperty(org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient, 
debug);

do your equivalent of this instead (I say equivalent on the off chance 
that you're using Log4J):
System.setProperty(org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient, 
error);

It strikes me personally that the warning in this particular context 
is probably excessive, and it should be logged as a info or debug 
message instead, but only in this particular case.  If you look at the 
wire log you'll notice that the server does not respond with a 
Content-Length header.  Rather, the length of the response is dictated 
by when the server closes the connection to the client.  HttpClient is 
telling the truth with this warning that you see, but in this particular 
context, the server explicitly indicates that it will be closing the 
connection.

Let us know if you think the logging change above is not sufficient to 
your needs.

-Eric.

Brad Clarke wrote:

I have a piece of code that hits my LinkSys router to get the IP address and
e-mail it if it has changed.
When using HTTPClient 2.0 RC1, it ran fine.  When I upgraded to RC2, I get
the message
WARNING: Response content length is not known

I've isolated the two calls that result in the warning.  They are:

   int status = client.executeMethod( get );
and
   get.getResponseBodyAsString();
Is there anything I can do to make this warning go away?

Here is the main procedure, to give you a better idea of what I'm doing:

   String strHTML = new String();
   String strIP = new String();
   int statusCode = 0;
   System.out.println(* LSRouter start *);

   HttpClient client = new HttpClient();

   client.getState().setCredentials(Linksys
BEFSR41/BEFSR11/BEFSRU31,
   192.168.1.1, new UsernamePasswordCredentials(user,
pass));
   GetMethod get = new GetMethod(http://192.168.1.1/Status.htm;);
   get.setDoAuthentication( true );
   //client.setStrictMode(true);  --- no effect when enabled
   //get.setStrictMode(true);  --- no effect when enabled
   // execute the GET
   int status = client.executeMethod( get );
   // print the status and response
   statusCode = get.getStatusCode();
   System.out.println(Status =  + statusCode);
   strHTML = StripHTML(get.getResponseBodyAsString());
   strIP = locateIP(strHTML);
   System.out.println(\n + strIP);

And the wire output:

2003/11/07 00:00:12:582 EST [DEBUG] HttpClient - -Java version: 1.4.2_02
2003/11/07 00:00:12:592 EST [DEBUG] HttpClient - -Java vendor: Sun
Microsystems Inc.
2003/11/07 00:00:12:592 EST [DEBUG] HttpClient - -Java class path:
D:\j2sdk1.4.2_02\jre\lib\rt.jar;D:\j2sdk1.4.2_02\lib\tools.jar;D:\Apache_Too
ls\commons-httpclient-2.0-rc2\commons-httpclient-2.0-rc2.jar;D:\Apache_Tools
\commons-httpclient-2.0-rc1\commons-httpclient-2.0-rc1.jar;D:\Apache_Tools\c
ommons-logging-1.0.3\commons-logging.jar;H:\Development\Java\LSRouter\classe
s
2003/11/07 00:00:12:592 EST [DEBUG] HttpClient - -Operating system name:
Windows 2000
2003/11/07 00:00:12:592 EST [DEBUG] HttpClient - -Operating system
architecture: x86
2003/11/07 00:00:12:592 EST [DEBUG] HttpClient - -Operating system version:
5.0
2003/11/07 00:00:13:844 EST [DEBUG] HttpClient - -SUN 1.42: SUN (DSA
key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom;
X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX
CertPathBuilder; LDAP, Collection CertStores)
2003/11/07 00:00:13:844 EST [DEBUG] HttpClient - -SunJSSE 1.42: Sun JSSE
provider(implements RSA Signatures, PKCS12, SunX509 key/trust factories,
SSLv3, TLSv1)
2003/11/07 00:00:13:844 EST [DEBUG] HttpClient - -SunRsaSign 1.42: SUN's
provider for RSA signatures
2003/11/07 00:00:13:854 EST [DEBUG] HttpClient - -SunJCE 1.42: SunJCE
Provider (implements DES, Triple DES, AES, Blowfish, PBE, Diffie-Hellman,
HMAC-MD5, HMAC-SHA1)
2003/11/07 00:00:13:884 EST [DEBUG] HttpClient - -SunJGSS 1.0: Sun (Kerberos
v5)
2003/11/07 00:00:14:555 EST [DEBUG]
HttpConnection - -HttpConnection.setSoTimeout(0)
2003/11/07 00:00:14:785 EST [DEBUG] HttpMethodBase - -Execute loop try 1
2003/11/07 00:00:14:795 EST [DEBUG] wire - - GET /Status.htm
HTTP/1.1[\r][\n]
2003/11/07 00:00:14:826 EST [DEBUG] HttpMethodBase - -Adding Host request
header
2003/11/07 00:00:14:996 EST [DEBUG] wire - - User-Agent: Jakarta

Re: HTTPClient RC2 - Response content length is not known

2003-11-07 Thread brm_dev

 HttpClient uses commons-logging for its configuration.  If you've 
 configued commons-logging properly, the message can be made to go away 
 as you indicated.  Since you already generated a wire log, presumably 
 you've seen the page for configuring logging.  My suggestion would be to 
 look at those instructions again, except change the logging level 
 (debug, info, warn, error).  Where you see this:
 System.setProperty(org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient,
  
 debug);
 
 do your equivalent of this instead (I say equivalent on the off chance 
 that you're using Log4J):
 System.setProperty(org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient,
  
 error);
 
 It strikes me personally that the warning in this particular context 
 is probably excessive, and it should be logged as a info or debug 
 message instead, but only in this particular case.  If you look at the 
 wire log you'll notice that the server does not respond with a 
 Content-Length header.  Rather, the length of the response is dictated 
 by when the server closes the connection to the client.  HttpClient is 
 telling the truth with this warning that you see, but in this particular 
 context, the server explicitly indicates that it will be closing the 
 connection.
 
 Let us know if you think the logging change above is not sufficient to 
 your needs.

I should have been more specific in my original posting.  I normally run the code with 
the wire log turned off.

I see these two warning messages on the screen when I run the program.  It's  most 
likely related to the fact that the LinkSys router doesn't really have a web server on 
it, but CGI-like interface.

I'll take a look at that log setting...that should be more than sufficient for my 
needs.

Thanks for the heads up on that.

Brad

1


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: HTTPClient RC2 - Response content length is not known

2003-11-07 Thread Oleg Kalnichevski
 It strikes me personally that the warning in this particular context 
 is probably excessive, and it should be logged as a info or debug 
 message instead, but only in this particular case.  If you look at the 
 wire log you'll notice that the server does not respond with a 
 Content-Length header.  Rather, the length of the response is dictated 
 by when the server closes the connection to the client.  HttpClient is 
 telling the truth with this warning that you see, but in this particular 
 context, the server explicitly indicates that it will be closing the 
 connection.

Eric, you are completely right. I realised that a few days ago and
already applied a fix for the problem. The most recent 2.0 code snapshot
will not display the warning when content length cannot be determined
but 'connection: close' directive is given.

Oleg


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: HTTPClient RC2 - Response content length is not known

2003-11-07 Thread Eric Johnson
Oleg,

Dang, you're good!  You complete fixes before others can even guess at them!

-Eric.

Oleg Kalnichevski wrote:

It strikes me personally that the warning in this particular context 
is probably excessive, and it should be logged as a info or debug 
message instead, but only in this particular case.  If you look at the 
wire log you'll notice that the server does not respond with a 
Content-Length header.  Rather, the length of the response is dictated 
by when the server closes the connection to the client.  HttpClient is 
telling the truth with this warning that you see, but in this particular 
context, the server explicitly indicates that it will be closing the 
connection.
   

Eric, you are completely right. I realised that a few days ago and
already applied a fix for the problem. The most recent 2.0 code snapshot
will not display the warning when content length cannot be determined
but 'connection: close' directive is given.
Oleg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: HTTPClient RC2 - Response content length is not known

2003-11-06 Thread Brad Clarke
Sorry...I subscribed to the wrong list.

Will repost on the user list.

Brad

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]