Re: getResponseBodyAsString() returns chunked HTTP content instead of resolved repsonse

2007-12-04 Thread Roland Weber
Pradeep Avadhani wrote:

 You have
 mentioned analyzing multi-threading, but I'm not sure how to uncover them on
 the client side. Any ideas?

If you are passing a MultiThreadedHttpConnectionManager to
the constructor of HttpClient, that client is thread safe.
If you don't, it is not.

cheers,
  Roland


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



Re: POST method problem(if read a request parameter)

2007-12-04 Thread Roland Weber
Hello Mukesh,

 HttpServletRequest request
 
 But if I read any request parameter from the request before executing
 the request, [...] The Post request fails [...]

If you call HttpServletRequest.getParameter(), the servlet
container will read the request entity to merge the parameters
sent in the body with the query parameters in the URL.

 I don't not have access to the external server, so I can't see what
 might be wrong. But this is quite strange behavior. I need access the
 above said request parameter in my servlet for some validation.

If it's a query parameter you need, try to obtain the URL
from the servlet request and get the parameter from there.
Otherwise, use HttpServletRequest.getParameter() and create
a new request entity from the parameters when forwarding
the request, instead of using getInputStream().

hope that helps,
  Roland


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



Socket closed for site

2007-12-04 Thread Saurabh AMBASTA
Hello, 

I have a website which opens with when pinged with IE or Firefox. However, 
when I try to send a request with the http client, I get a socket closed 
exception. 

I have tried to set the same headers as sent by Mozilla but still not able 
to solve this issue.

2007/12/04 14:12:38:171 CET [DEBUG] HttpClient - Java version: 1.3.1_20
2007/12/04 14:12:38:171 CET [DEBUG] HttpClient - Java vendor: Sun 
Microsystems Inc.
2007/12/04 14:12:38:181 CET [DEBUG] HttpClient - Java class path: 
TRT.jar;lib\xerces.jar;lib\commons
-logging-api-1.1.jar;lib\commons-codec-1.3.jar;lib\SiebelJI.jar;lib\SiebelJI_Common.jar;lib\SiebelJI
_enu.jar;lib\commons-httpclient-3.1-alpha1.jar;lib\dm_m12.jar;lib\javautils.jar;lib\jcert.jar;lib\jn
et.jar;lib\jsse.jar
2007/12/04 14:12:38:191 CET [DEBUG] HttpClient - Operating system name: 
Windows XP
2007/12/04 14:12:38:191 CET [DEBUG] HttpClient - Operating system 
architecture: x86
2007/12/04 14:12:38:191 CET [DEBUG] HttpClient - Operating system version: 
5.1
2007/12/04 14:12:38:191 CET [DEBUG] HttpClient - SUN 1.2: SUN (DSA 
key/parameter generation; DSA sig
ning; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS keystore)
2007/12/04 14:12:38:201 CET [DEBUG] HttpClient - SunRsaSign 1.42: SUN's 
provider for RSA signatures
2007/12/04 14:12:38:211 CET [DEBUG] DefaultHttpParams - Set parameter 
http.useragent = Jakarta Commo
ns-HttpClient/3.1-alpha1
2007/12/04 14:12:38:211 CET [DEBUG] DefaultHttpParams - Set parameter 
http.protocol.version = HTTP/1
.1
2007/12/04 14:12:38:221 CET [DEBUG] DefaultHttpParams - Set parameter 
http.connection-manager.class
= class org.apache.commons.httpclient.SimpleHttpConnectionManager
2007/12/04 14:12:38:231 CET [DEBUG] DefaultHttpParams - Set parameter 
http.protocol.cookie-policy =
default
2007/12/04 14:12:38:251 CET [DEBUG] DefaultHttpParams - Set parameter 
http.protocol.element-charset
= US-ASCII
2007/12/04 14:12:38:251 CET [DEBUG] DefaultHttpParams - Set parameter 
http.protocol.content-charset
= ISO-8859-1
2007/12/04 14:12:38:261 CET [DEBUG] DefaultHttpParams - Set parameter 
http.method.retry-handler = or
[EMAIL PROTECTED]
2007/12/04 14:12:38:271 CET [DEBUG] DefaultHttpParams - Set parameter 
http.dateparser.patterns = [EE
E, dd MMM  HH:mm:ss zzz, , dd-MMM-yy HH:mm:ss zzz, EEE MMM d 
HH:mm:ss , EEE, dd-MMM-
 HH:mm:ss z, EEE, dd-MMM- HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE 
dd-MMM- HH:mm:ss z, EEE
 dd MMM  HH:mm:ss z, EEE dd-MMM- HH-mm-ss z, EEE dd-MMM-yy 
HH:mm:ss z, EEE dd MMM yy HH:mm:s
s z, EEE,dd-MMM-yy HH:mm:ss z, EEE,dd-MMM- HH:mm:ss z, EEE, dd-MM- 
HH:mm:ss z]
2007/12/04 14:12:38:291 CET [DEBUG] DefaultHttpParams - Set parameter 
http.protocol.cookie-policy =
rfc2109
http://partenaires.lexmark.fr/
2007/12/04 14:12:38:331 CET [DEBUG] DefaultHttpParams - Set parameter 
http.socket.timeout = 5000
2007/12/04 14:12:38:341 CET [DEBUG] DefaultHttpParams - Set parameter 
http.useragent = Mozilla/5.0 (
Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 
Firefox/2.0.0.9
2007/12/04 14:12:38:341 CET [DEBUG] DefaultHttpParams - Set parameter 
http.connection = Keep-Alive
2007/12/04 14:12:38:361 CET [DEBUG] HttpConnection - Open connection to 
partenaires.lexmark.fr:80
2007/12/04 14:12:59:371 CET [DEBUG] HttpMethodDirector - Closing the 
connection.
2007/12/04 14:12:59:371 CET [INFO] HttpMethodDirector - I/O exception 
(java.net.ConnectException) ca
ught when processing request: Connection refused: connect
2007/12/04 14:12:59:371 CET [DEBUG] HttpMethodDirector - Connection 
refused: connect java.net.Conne
ctException: Connection refused: connectjava.net.ConnectException: 
Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:350)
at 
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:137)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:124)
at java.net.Socket.init(Socket.java:268)
at java.net.Socket.init(Socket.java:147)
at 
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(Unknown
Source)
at 
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(Unknown
Source)
at org.apache.commons.httpclient.HttpConnection.open(Unknown 
Source)
at 
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(Unknown 
Source)
at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(Unknown 
Source)
at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown 
Source)
at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown 
Source)

Please let me know what I am doing wrong here.

thanks and regards,
Saurabh Ambasta

Phone : 33 - (0) 2 38 71 1508 
Email : [EMAIL PROTECTED]

Re: Socket closed for site

2007-12-04 Thread Puneet Lakhina
On Dec 4, 2007 6:57 PM, Saurabh AMBASTA
[EMAIL PROTECTED] wrote:
 Hello,

 I have a website which opens with when pinged with IE or Firefox. However,
 when I try to send a request with the http client, I get a socket closed
 exception.

 I have tried to set the same headers as sent by Mozilla but still not able
 to solve this issue.

Do you access these sites in your browser through a proxy??If yes then
you will have to set up http client to use that proxy.

httpclient.getHostConfiguration().setProxy(myproxyhost, 8080);
  httpclient.getState().setProxyCredentials(my-proxy-realm,  myproxyhost,
  new UsernamePasswordCredentials(my-proxy-username, my-proxy-password))

-- 
Puneet
http://sahyog.blogspot.com/

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



socket time out

2007-12-04 Thread Sébastien Geindre

hi all,

i have a pb with socket established by httpclient.
they fall down after 10 seconds !

PostMethod post = new PostMethod(http://.;);
post.getParams().setSoTimeout(new Integer(15));

2007-12-04 17:40:38,780 main TRACE methods.EntityEnclosingMethod - enter 
EntityEnclosingMethod.hasRequestContent()
2007-12-04 17:40:38,780 main TRACE httpclient.HttpConnection - enter 
HttpConnection.getRequestOutputStream()
2007-12-04 *17:40:48*,807 main DEBUG httpclient.HttpMethodDirector - 
Closing the connection.
2007-12-04 17:40:48,807 main TRACE httpclient.HttpConnection - enter 
HttpConnection.close()
2007-12-04 17:40:48,807 main TRACE httpclient.HttpConnection - enter 
HttpConnection.closeSockedAndStreams()
2007-12-04 17:40:48,808 main DEBUG transformer.WFSProxyHttpClient - 
HttpMethodRetryHandler Exception : Broken pipe



10 second after the first write on the socket, it fall down.


any idea ???

The server needs more than 10 seconds to process the service...I know 
it's too long...

thanks

--
Sébastien Geindre
DPREVI/AERO/DEV
sebastien.geindre __at__ meteo.fr




Re: getResponseBodyAsString() returns chunked HTTP content instead of resolved repsonse

2007-12-04 Thread Pradeep Avadhani
Yes, that is being done in the code.
**
*this*.conManager = *new* MultiThreadedHttpConnectionManager();

HttpConnectionManagerParams params = *new* HttpConnectionManagerParams();
params.setMaxTotalConnections(*this*.config.getMaxConnections());
params.setDefaultMaxConnectionsPerHost(*this*.config.getMaxConnections());
params.setMaxTotalConnections(*this*.config.getMaxConnections());
*this*.conManager.setParams(params);

*this*.clientParams = *new* HttpClientParams();
*this*.clientParams.setSoTimeout(*this*.config.getTimeout());

HttpClient client = *new* HttpClient();

client.setHttpConnectionManager(*this*.conManager);
client.setParams(*this*.clientParams);


On 12/4/07, Roland Weber [EMAIL PROTECTED] wrote:

 Pradeep Avadhani wrote:

  You have
  mentioned analyzing multi-threading, but I'm not sure how to uncover
 them on
  the client side. Any ideas?

 If you are passing a MultiThreadedHttpConnectionManager to
 the constructor of HttpClient, that client is thread safe.
 If you don't, it is not.

 cheers,
 Roland


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




Re: Performance Issues with Transfer-Encoding chunked

2007-12-04 Thread vzs64

Any suggestions for improving performance welcome. 

The server is sending exceptions alongwith the page, any other way to reduce
download time other than writing to WebMaster of the site.



-- 
View this message in context: 
http://www.nabble.com/Performance-Issues-with-Transfer-Encoding-chunked-tf4928640.html#a14157626
Sent from the HttpClient-User mailing list archive at Nabble.com.


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



Threads problem - too many errors.

2007-12-04 Thread Krzysztof Zimnicki

Hello.

My application using threads, do 1000-1 conections. I create 20-30 
threads and at begining everything is fine, but 2-3h later i have only 
50% works threads. I don't know what is wrong, and have more errors than 
at begining. My code:




import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.methods.GetMethod;

public class SingleCheck extends Thread {

   private static BufferedReader fileUrl = null;
   private HttpClient client = null;
   private GetMethod get = null;

   public SingleCheck(String id)
   throws FileNotFoundException {
   super(id);
   System.out.println(id);

   client = new HttpClient(new MultiThreadedHttpConnectionManager());
   client.getHttpConnectionManager().getParams().setConnectionTimeout(
   1);
   get = new GetMethod();

   if (fileUrl == null) {
   fileUrl = new BufferedReader(new FileReader(new File(
   URLS.txt)));
  
   }


   }

   synchronized String pobierzURL() throws IOException {

   return fileUrl.readLine();

   }

   boolean check(String url) throws HttpException,
   IOException {
   try {
   URI uri = new URI(url, true);
   get.setURI(uri);

   get.addRequestHeader(Connection, close);
  
   client.executeMethod(get);


   Header[] headers = get.getResponseHeaders();
   for (int i = 0; i  headers.length; i++) {

   if (headers[i].getName().contains((Location))) {
   return true;
   }
   }
   return false;
   } finally {
   get.releaseConnection();
   }
   }

   public void run() {

   String url = ;
   while (url != null) {
   try {
   url = this.pobierzURL();
   System.out.println(Watek nr:  + getName() +   + url);
   if (this.check( url)) {
   //add to file if url is good
   ZarzadzanieWynikami.addToFile( url,goodUrls.txt);
   }
   } catch (Exception e) {
   e.printStackTrace();
   System.out.println(Exception catch);
   }
   }

   }
}

and main file:

public class MainLoginCheck {

   /**
* @param args
*/
   public static void main(String[] args) {
   try {
   


   System.out.println(args[1]);
   int iloscWatkow = Integer.parseInt(args[0]);
   String haslo = args[1];

   for (int i = 0; i  iloscWatkow; i++) {
   new SingleCheck(  + i).start();
   }
   } catch (Exception e) {
   e.printStackTrace();
   }
   }

}


Many of errors:

java.net.SocketException: Connection reset
   at java.net.SocketInputStream.read(Unknown Source)
   at java.io.BufferedInputStream.fill(Unknown Source)
   at java.io.BufferedInputStream.read(Unknown Source)
   at 
org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
   at 
org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
   at 
org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
   at 
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
   at 
org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
   at 
org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
   at 
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
   at 
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
   at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
   at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
   at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)

   at SingleCheck.login(SingleCheck.java:61)
   at SingleCheck.run(SingleCheck.java:90)


Any idea?




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