Re: Problem with MultiThreading

2007-12-12 Thread Roland Weber
afmustac wrote:
> java.net.SocketException: Connection reset

That is not a multithreading problem, it is a problem with
the server you are connecting to. Make sure you have the
proxy configuration set up correctly. Try to access the
server with a browser, then take that browser's proxy settings
and establish them in your application.

cheers,
  Roland


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



Re: HttpClient Headers

2007-12-12 Thread Roland Weber
Hello Bashiro,

> Dec 11, 2007 7:47:51 PM 
> org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
> INFO: basic authentication scheme selected
> Dec 11, 2007 7:47:51 PM org.apache.commons.httpclient.HttpMethodBase 
> getResponseBody
> WARNING: Going to buffer response body of large or unknown size. Using 
> getResponseAsStream instead is recommended.
> 
> How do I remove the debug headers above;

These are not headers, these are debug messages. Or rather
one INFO and one WARNING message. You can get rid of the
INFO message by configuring your logging framework properly.
See our logging guide for pointers, and the documentation
of your logging framework for details:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/logging.html

You could get rid of the warning by configuring the logging
framework too, but I wouldn't recommend that. Either do as
the message tells you and don't call getResponseBody, or
configure the warning limit properly:

http://jakarta.apache.org/httpcomponents/httpclient-3.x/preference-api.html
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html#BUFFER_WARN_TRIGGER_LIMIT

> example, how do I change the apache to my client name, and how do I 

What does that have to do with the log output above?
You can change some header values by setting them before
executing the method. You can change the user-agent
header value by setting a parameter:

http://jakarta.apache.org/httpcomponents/httpclient-3.x/preference-api.html
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html#USER_AGENT

hope that helps,
  Roland


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



Re: Handling MIME multipart response

2007-12-11 Thread Roland Weber
ripok wrote:
> What is the easy way to handle this kind of response with HttpClient?

HttpClient does not care what kind of response you get.
It will not help you at all. There are various other
libraries with multipart parsing functionality, which
may require different levels of custom coding...

http://james.apache.org/mime4j/index.html
(designed for emails)

http://commons.apache.org/fileupload/
(designed for Servlets and Portlets, will require a custom adapter)

JavaMail
http://java.sun.com/products/javamail/javadocs/index.html
(designed for emails)

hope that helps,
  Roland

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



Re: socket time out

2007-12-11 Thread Roland Weber
Hello Sébastien,

> i have set a low level of debug, and it's better; but still drop the
> connection sometimes.

Have you found a correlation between input data and the connections
being dropped? Is it a particular request for which the connection
is dropped, or does the same request sometimes go through and other
times fail? A correlation with load on the server or network?

> how can i monitor jetty thread ?

It's just an idea that there might be such a thread. Or maybe
some timeout settings on the server socket. Please ask Jetty
questions on a Jetty mailing list.

> i put the breakpoint because i does not work in 'normal' environment.

Does not work reproducibly (depends on the request being sent)
or does not work sporadically (timing problem)?

cheers,
  Roland


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



Re: isOpen returns true even when network interface disabled

2007-12-10 Thread Roland Weber
Hello Paolo,

HttpConnection.isOpen just checks the boolean flag in the
connection object, it doesn't perform any calls to the
underlying socket. Try calling conn.closeIfStale() before
checking if the connection is open:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpConnection.html#closeIfStale()

I can't tell whether that is reliable, though.

hope that helps,
  Roland


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



Re: socket time out

2007-12-10 Thread Roland Weber
Hello Sébastien,

> i start the small client
> i see the server stopped at the breakpoint.
> 
> i just do nothing, every body is waiting.
> and after 10 seconds, the connection dropped !!

You don't expect the system to behave normally when
you stop the service thread with a break point, do you?
If the request size plays a role, then probably some
buffer runs full, while with a small request everything
fits into the buffer. If the 10 second delay is
reproducible with different sizes of large requests,
I would go looking for a monitor thread in Jetty that
kills connections or hanging service threads.

Remove the breakpoint, see if the code works then.
If it does, the problem is in your server debugging
environment.

hope that helps,
  Roland


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



Re: Send InputStream via PostMethod

2007-12-10 Thread Roland Weber
Rooboo wrote:
> Ok for Now I just set the InputStreamRequestEntity, but I also don't get it
> really in the servlet, because it seems to be empty.

What MIME type are you using? I suggest something like
application/binary or application/x-your-app-name.
If you call request.getParameter() on the server side,
the Servlet container might read the stream if the
MIME type indicates parameters.

hope that helps,
  Roland


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



Re: Performance Issues with Transfer-Encoding chunked

2007-12-08 Thread Roland Weber
vzs64 wrote:
> 
>> Interpret the exceptions and fix the cause. Most likely,
>> the server doesn't like what you are sending. What do
>> you mean by "along with the page"?
> 
> The server is a public website not under my control.

I didn't say you should fix the server. Fix what you are
sending there until it doesn't reply with exceptions anymore.

cheers,
  Roland


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



Re: HttpClient 3.1 / JavaHttp TIME_WAIT differences

2007-12-07 Thread Roland Weber
Oleg Kalnichevski wrote:
> It would be nice to put all this information into a connection
> management guide of some kind or a FAQ.

Done. Please review, correct and extend:
http://wiki.apache.org/jakarta-httpclient/FrequentlyAskedConnectionManagementQuestions

I omitted a discussion of HttpURLConnection.disconnect(),
HttpMethod.abort() and ConnectionReleaseTrigger.
The next entry in the CM FAQ, which would best be the
first entry, should be about the difference between
closing a stream and closing a connection.

cheers,
  Roland


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



Re: socket time out

2007-12-07 Thread Roland Weber
Hello Sébastien,

>>> 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
>>   
> no nothing between this 2 steps...no trace...
> in fact in the code :
>OutputStream outstream = conn.getRequestOutputStream();
>  if (contentLength < 0) {
>outstream = new ChunkedOutputStream(outstream);
>}
>  requestEntity.writeRequest(outstream);
> 
> so it took time to write the request...

So the socket doesn't fall down after 10 seconds (which would
indicate a timeout problem) but when the request is sent and
a response would be expected. This indicates that either the
server or (more likely) some firewall inbetween doesn't like
the request you are sending and simply drops the connection.
A server would be expected to send a 4xx response, that's why
I suspect a firewall. We had one case where a firewall didn't
like the "User-Agent" header that HttpClient sends by default.
Replacing that with the User-Agent of some well-known browser
solved the problem.

> the post is an xml post of data, quite heavy...
> 646213  bytes of data, is too heavy ?

The size of the data is not the problem.

a) Can you test with smaller or larger XML data?
That would help to verify that it is not a timeout problem
but occurs always after the full request is sent.

b) Do you have another application that successfully
   communicates with that server?
Then you could compare a request sent by that application
with the request sent by your application.

hope that helps,
  Roland

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



Re: Performance Issues with Transfer-Encoding chunked

2007-12-06 Thread Roland Weber
vzs64 wrote:
> The server is sending exceptions alongwith the page, any other way to reduce
> download time other than writing to WebMaster of the site.

Interpret the exceptions and fix the cause. Most likely,
the server doesn't like what you are sending. What do
you mean by "along with the page"?

cheers,
  Roland


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



Re: HttpClient 3.1 / JavaHttp TIME_WAIT differences

2007-12-06 Thread Roland Weber
Hi Sebastian,

> If HttpClient (or my app) is failing to close sockets at the end,
> perhaps it needs to be enhanced - otherwise it will be causing the
> server to go into TIME_WAIT instead?

I'm not sure whether the server needs to go into TIME_WAIT
if it gets a reset packet. But it can't hurt to call
SimpleHttpConnectionManager.shutdown() when exiting
the application. Looks like we forgot to add that method
to the interface, but it's too late for 3.1 now.

I wouldn't want to mess with shutdown hooks [1] by default,
but I will remember the problem when we start working on
an HttpClient 4.0 Tutorial.

cheers,
  Roland

[1]
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)



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



Re: socket time out

2007-12-04 Thread Roland Weber
Hello Sébastien,

this doesn't look like a full trace to me:

> 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

What's going on around (*)? Is the request body written correctly?
Any IOExceptions? Feel free to remove actual data of the body, but
please provide the parts of the log that tell us what's happening.

cheers,
  Roland

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



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]



Re: Performance Issues with Transfer-Encoding chunked

2007-12-02 Thread Roland Weber
Hello,

Transfer-Encoding and Content-Encoding are two completely
separate things. I'm pretty sure that Content-Encoding:gzip
is sent with Transfer-Encoding:chunked. If you want server
responses with content compression, send a header to that effect
in your request, and decompress the response accordingly.
There is example code for HttpCore at [1].

You can generate a wire log [2] to see what data is sent and
received. Depending on the logging framework you use, you
can also get timestamps for the log entries which will show
where the delay happens. Feel free to post wire logs to this
mailing list if you need help with interpreting them.

cheers,
  Roland

[1]
http://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/compress/
[2] http://jakarta.apache.org/httpcomponents/httpclient-3.x/logging.html

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



Re: Another Form-problem, cookies?

2007-11-29 Thread Roland Weber
distortion wrote:
> 
> Did some scanning with WireShark and noticed that when i log in to the site
> using Firefox the GET /my.php, which is redirected from /login.php, the
> http-packet contains a Referer, that says:
> Referer: http://www.torrentbytes.net/login.php\r\n
> 
> And when i attempt the same thing with my Java-program the http-packet for
> GET /my.php doesn't have any Referer at all, so I'm guessin' that this is
> what's causing my problems. Is it possible to send a Referer-attribute or
> something?

Sure:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpMethod.html#setRequestHeader(java.lang.String,%20java.lang.String)

cheers,
  Roland


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



Re: Another Form-problem, cookies?

2007-11-29 Thread Roland Weber
Mathias Söderberg wrote:
> Hi!
> I, like many others, are trying to login to a website using HttpClient and
> the PostMethod. When running the program I'm getting the following result:
> 
> Login form get: HTTP/1.1 200 OK
> Initial set of cookies:
> - PHPSESSID=4c3499e030f2e09c35e5af6fb20571f0
> - checksum=f2d870271e0887c854fd041ad746cb78
> Login form post: HTTP/1.1 200 OK
> Logon cookies:
> - PHPSESSID=4eb20a61a4a09f4cf89db46af25affb2
> - checksum=0a8a452f089ad78ce3b0ea670d0d8011

So the POST of the login form returns a page instead of a redirect.
Have you taken a look at that page? Maybe it's the one you want.
If not, it may contain an error description.

cheers,
  Roland


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



Re: domain argument in AuthScope constructor ineffective for NTLM

2007-11-27 Thread Roland Weber
Hello,

> I have repeated this code a few times to set different credentials for
> different domains. In NTLM type 2 response from the server, the server
> sends the NTLM domain it expects for authentication.

I assume that "type 2 response" has nothing to do with NTLMv2, which
is unsupported:
http://wiki.apache.org/jakarta-httpclient/FrequentlyAskedNTLMQuestions

> However, I find that the httpclient pays no heed to the domain name
> specified in NTLM type 2 response. It simply goes ahead with
> authentication with an arbitrary credentials. Is this an expected
> behavior?

Probably not. Unfortunately, nobody here (that I am aware of) is familiar
with the NTLM code in HttpClient. We all just hope that it works without
problems until we can replace it by jCIFS or whatever.

Please open a bug report in JIRA.[1] If you can provide a testcase
similar to those in [2] that exposes the problem, I will have a look
at it within the next two months. Otherwise, it will have to wait
until we get around to addressing NTLM authentication in 4.0, which
may take a year.

cheers,
  Roland

[1] https://issues.apache.org/jira/
[2] http://wiki.apache.org/jakarta-httpclient/FrequentlyAskedNTLMQuestions


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



Re: Redirect not working of POST

2007-11-23 Thread Roland Weber
terry_513 wrote:
> It would be very kind of you, if you can guide me with the fields. Setting
> select, check box, other mentioned above & hidden fields.

It's all in the primer:
http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners#head-93d017d102ea8a83b2ad6e07c5184ec2f922f09a

cheers,
  Roland

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



Re: Problem with MultiPartPostMethod when long string added in parameter

2007-11-22 Thread Roland Weber
Hello Nitya,

have you tried to change the order of the parameters?
Since you are obviously hitting a problem in the parser
on the server side, that might be a workaround.

hope that helps,
  Roland

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



Re: ValidatorException

2007-11-22 Thread Roland Weber
You are welcome to suggest improvements to our SSL Guide:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/sslguide.html

cheers,
  Roland

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



Re: Redirect not working of POST

2007-11-22 Thread Roland Weber
If you get a redirect to the same form you came from,
that typically means that the server didn't like the
data you entered. In a browser, you'd probably see
an additional message like "you have to enter a value
in this field".
Check the data you are posting. Check twice that you
send all hidden parameters, and a value for every
field where you have to enter data, and for every
checkbox you have to set. It's best to grab the request
sent by a browser and compare the data. There may even
be some JavaScript somewhere in the page that modifies
the parameters or target URL when the form is submitted
by a browser.

hope that helps,
  Roland

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



Re: Problem with MultiPartPostMethod when long string added in parameter

2007-11-17 Thread Roland Weber
nitya vyas wrote:
> 
> The problem i am facing is that i have a String parameter which will store
> number of files being uploaded in comma separated string.. 1,2,3,... etc

Why would you do that? If it's just all numbers from 1 to n,
then send n instead and let the server interpret that.
In general, you cannot assume that a server will be able to
process parameters with arbitrary length, or that all browsers
will be able to generate them. Limits are implementation specific.

> The value which i get for the long string parameter 1,2,3,4,5.. upto 300 is
> not got properly and there are garbage values in that...

Can you be more specific about the garbage values?
Something like line breaks?

> wat can be done to get the value of the long string correctly by
> parseRequest on server??

I suggest you use the wire log on the client side to get the
exact value that is sent for the parameter. Compare something
that works (...200) with one that fails (...300). Then we can
check whether what we send is comopliant with the spec.

As mentioned above, the best way to fix this problem is to
avoid excessively long parameter values.

hope this helps,
  Roland



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



Re: https and aspx

2007-11-10 Thread Roland Weber
ggcampbell wrote:
> After figuring out about the single header my self I found your reference to
> http.protocol.single-cookie-header
> But I found some weird sites that accept only single header cookies but send
> multi
> header cookies.

And why should they not? Cookie: and Set-Cookie: are two completely
different headers, which are interpreted and composed by different
code on either side of the connection.

> By turning on http.protocol.single-cookie-header the
> response headers
> were missinterpreted skipping the second and later cookies.

You must have gotten something wrong there. The single-cookie-header
in HttpClient is interpreted exclusively by the code that generates
the Cookie: header. The code that interprets the incoming cookies is
completely independent from that. Of course there are other possible
causes for not interpreting returned cookies correctly. The most
likely explanation is that you had the wrong cookie policy configured
for the respective site.
http://jakarta.apache.org/httpcomponents/httpclient-3.x/cookies.html
If none of the cookie policies work, please open bug reports in JIRA
and include the Set-Cookie: headers that were not interpreted correctly.

> httpclient.getParams().setParameter("http.protocol.expect-continue",true);
> Would it make any difference to make this the default behavior of
> HttpClient?

Of course it would make a difference - why should you ask for
that change if it wouldn't? And if it changes your code from
being broken to working correctly, it is sure to break other
people's code from working correctly to being broken. Besides,
development of 3.1 has ended. We will only fix severe bugs in
the old codebase. No enhancements, no cosmetics, and surely
no change in default behavior.
For the 4.0 codebase, all the examples I remember had that
parameter set to true. It comes with a performance penalty for
small payloads, since there is an additional round trip even
if the request and payload would fit into a single IP packet.

cheers,
  Roland


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



Re: Repeated Proxy-Authorization Challenges

2007-11-09 Thread Roland Weber
Kevin Crosbie wrote:
> Hi,
> 
> I've written an app that makes Post requests using an instance of
> HttpClient.
> My app sometimes talks through a Proxy server using the Digest scheme

IIRC, the 3.1 implementation of the digest scheme is suboptimal
and runs a challenge-response exchange for every request.

Oleg, please correct me if I'm wrong.

> * Does HttpClient support resending of authorization information?

For BASIC auth, yes. I'm not sure about the other schemes.

> * If it does (I assume it does), how does one make this happen?

You have to enable "preemptive authentication". That doesn't work
for DIGEST, because DIGEST requires a server challenge in order
to compute the Authorization header. It should be possible to
store the challenge once it is received and use it to authenticate
future requests, but that's where I believe the implementation
is suboptimal. Additionally, a server may choose to change the
challenge.

> * If the default behaviour is to resend, what could I be doing that
> causes it to not happen.
>   Things that come to mind are:
>  - calling PostMethod.setDoAuthentication(true);

Without that, HttpClient will not authenticate at all.

>  - finishing each post with PostMethod.releaseConnection();

That's a must.

>  - Using a new instance of a PostMethod every time

That's strongly recommended, there is no point in
re-using method instances.

hope that helps,
  Roland


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



Re: How to authenticate and then send a HTTP Post to one server?

2007-11-09 Thread Roland Weber
Alexander Philippi wrote:
> Hi,
> I am sending XML Streams via HTTP POST to another server. But since this
> week I have to authenticate to this server (I don't really know what kind
> of authentication but I think its BASIC).
> I could not "pack" the authentication Information (user and pass) to the
> HTTP POST because the server reads the whole payload

Credentials for BASIC authentication are passed as headers,
not in the payload. They have to be sent with every request.
We have an authentication guide:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/authentication.html
And there is information about authentication in the
Application Design FAQ, too:
http://wiki.apache.org/jakarta-httpclient/FrequentlyAskedApplicationDesignQuestions#head-3a19c5b1f6f198138c930d6cdda1c6611ca00e62

hope that helps,
  Roland

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



Re: HttpClient No ClassDefFoundError

2007-11-09 Thread Roland Weber
Angso, Tony wrote:
> Am using RAD6 (Websphere6)

That's basically Eclipse. Yak ;-)

> The class path is both in .ClassPath file and also configured in
> Websphere JVM classPath

Don't define classes in the JVM classpath. If you are implementing
a web application, put the JARs in WEB-INF/lib/. If it's an ear,
there is another level in the ear file where you can put the JARs.
If you put something like commons-logging too high up into the
classloader hierarchy, for example above log4j, it is likely to
try and reference classes via the thread context classloader for
which it cannot resolve the dependencies correctly.

hope that helps,
  Roland

>path="C:/Tony/Download/Java/log4j/apache-log4j-1.2.15/log4j-1.2.15.jar"/
>path="C:/Tony/Download/Java/shared/jars/commons-logging-1.1.jar"/>
>path="C:/Tony/Download/Java/shared/jars/commons-codec-1.3.jar"/>
>path="C:/Tony/Download/Java/shared/jars/commons-httpclient-3.1.jar"/>


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



Re: How to use http client ro request part of a file in HTTP request?

2007-11-08 Thread Roland Weber
ying lcs wrote:
> Thanks. But what http request header I need to set in order to achieve
> a partial get?

The Range: header. Note that servers do not have to support that, they
can simply return the full document. Make sure to check which ranges
are indicated in the response.
http://tools.ietf.org/html/rfc2616#section-14.35

cheers,
  Roland


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



Re: Problem with QueryString

2007-11-07 Thread Roland Weber
Hi,

 the . in the parameter may be encoded as %2e by the
setQueryString method. That is identical as far as the
specification is concerned, but maybe your server
doesn't care about it. Try using the setQueryString(String)
method instead, performing an encoding that leaves the
. character unchanged.

hope that helps,
  Roland

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



Re: java.io.IOException: Bad chunk size??

2007-11-07 Thread Roland Weber
AlliumPorrum wrote:
> Server: Sun-Java-System/Application-Server
> Date: Wed, 07 Nov 2007 17:44:10 GMT
> Content-Type: text/html; ISO-8859-1;charset=ISO-8859-1
> X-powered-by: Servlet/2.4
> Transfer-Encoding: chunked
> 200 OK

I have no idea how someone manages to send non-chunked data
through the Servlet API, when the container is supposed to
chunk-encode the response data. But the Content-Type looks
fishy too, so somebody seems to have messed up badly.

> So, the server really claims to use "chunked" messages. But the question now
> is; how can I solve this problem in the HTTP client side, because the server
> isn't made by me??

I'm afraid you'll have to hack into the HttpClient source code
and change the interpretation of the Transfer-Encoding header.
That's in HttpMethodBase.readResponseBody(HttpConnection). Maybe
you can simply add some code that deletes the Transfer-Encoding
header before that method is called. But you must only do that
if the response is coming from that broken server, otherwise
you'll screw things up for servers that work correctly.

cheers,
  Roland

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



Re: java.io.IOException: Bad chunk size??

2007-11-06 Thread Roland Weber
Looks like the server claims to send a chunked message,
but then sends plain text without chunk information.
Check what value the Transfer-Encoding header of the
response has. If that says "chunked", but the server
doesn't chunk-encode the response, you'll get that kind
of exception.

hope that helps,
  Roland

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



Re: file progress

2007-11-04 Thread Roland Weber
Robin Batra wrote:
> is there a way by which we can track the file upload progress
> 
Write your own request entity that generates progress notifications
during the upload. You'll find discussions about this in the
mailing list archives.

cheers,
  Roland


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



Re: Problem with redirection on password protected website

2007-11-02 Thread Roland Weber
giuseppe italiano wrote:
> I've read at
> http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners
> but I can't find what's wrong in my code

Don't just read it, follow the instructions. Make a trace of
the requests that a browser or some other program sends, then
compare against what your code is sending with HttpClient.
If you don't know how to compare, send the traced requests
to this mailing list.
Before you do that, please find a way to post well-formatted
messages. What you are currently sending has all line breaks
completely screwed up, at least in my mail client.

cheers,
  Roland



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



Re: FYI: typo/error in HttpClient site

2007-11-02 Thread Roland Weber
Thanks for letting us know. We'll fix it.

cheers,
  Roland

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



Re: Hi Encountered Software Caused Connection Abort Exception

2007-11-02 Thread Roland Weber
Hello Bala Mali,

do you have personal firewall software running?
Try to switch it off, or to define a rule for your
program.

Another potential problem is your use of many
instances of HttpClient. Make sure that the
SimpleConnectionManager you are using is set
to shutdown connections on release. By default,
it will keep them open and you may run into
problems with Windows network settings. There
are also changes to the Windows network settings
you could apply to ensure there are enough local
ports available for your application. There are
some links in the mailing list archives.

hope that helps,
  Roland

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



Re: Problem with redirection on password protected website

2007-11-01 Thread Roland Weber
Hello Guiseppe,

have you followed the instructions in the primer?
http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners

hope that helps,
  Roland

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



Re: Hi Encountered Software Caused Connection Abort Exception

2007-11-01 Thread Roland Weber
Where is the stack trace?

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



Re: Hi Encountered Software Caused Connection Abort Exception

2007-11-01 Thread Roland Weber
Bala mani wrote:
> Hi,
>  I am performing Load Testing for a web based application and
> when the load size reaches 100 users. the Httpclient modules throws Software
> Caused Connection Abort Exception.

Where is the stack trace? What are the limits you configured
on the server side?

cheers,
  Roland


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



Re: how can i control MSS size?

2007-11-01 Thread Roland Weber
Hi Lior,

> i am doing a test that check our server behavior while sending different MSS
> sizes.

I've never heard that acronym in the context of HTTP.
If it's a TCP/IP setting, please check the documentation
of the JVM you are using. You can install custom socket
factories to manipulate socket configuration.

hope that helps,
  Roland


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



NoClassDefFoundError (was: Re: postmethod does not work)

2007-11-01 Thread Roland Weber
phantom fdfd wrote:
> 
> java.lang.NoClassDefFoundError: org/apache/http/protocol/HttpExecutionContext

HttpClient 4.0 needs HttpCore 4.0, and a few other dependencies as well.
Make sure that _all_required libraries are in your classpath.

When you start a new discussion on a mailing list, please send
a mail directly and choose an appropriate subject. Do NOT just
"reply to" a mail in a totally unrelated discussion.

cheers,
  Roland


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



Re: How to set http proxy details without coding

2007-10-21 Thread Roland Weber
Sagi Mann wrote:
> Hello,
> I was wondering if it is possible to set proxy info (host, port,
> credentials, authscope, etc) without using code, i.e. via
> configuration, external property file, etc.

No. We have no idea where you - or any other HttpClient user - would
like to read that config from, or in what format you'd like to have it.

> This way, I don't have to
> implement my own config-reader just for these settings...

Why don't you implement your own config-reader for all
your application settings?

cheers,
  Roland


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



Re: getHostConfiguration

2007-10-21 Thread Roland Weber
Hello,

> AFAIK, it is the HttpMethod instances, through multiple
> HttpConnections, that connect to various hosts. If so, could anyone
> pls explain what is HttpClient.getHostConfiguration used for? After
> all, an HttpClient shouldn't be associated with any specific host,
> correct?


Every connection is made based on a HostConfiguration, which tells
HttpClient what proxy to use or what local address. Also, you can
create a method with a relativ URL that doesn't specify the host.
The HostConfiguration in the HttpClient is the default host config
for relative URLs.

hope that helps,
  Roland

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



Re: Should Multiple threads use same HttpClient object

2007-10-19 Thread Roland Weber
Puneet Lakhina wrote:
> I hope I am interpreting it right.

yes

> If i am making threads by implementing
> Runnable, then the HttpClient instance should be a static variable,
> something like the following.
> public MyThreads implements Runnable{
> private static HttpClient client = new HttpClient(new
> MultiThreadedHttpConnectionManager());
> public void run() {
> try {
> client.executeMethod(method);
> }finally {
> method.releaseConnection();
> }
> }
> }
> 
> hope that helps,
>>   Roland
>>
>> -
>> 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: Should Multiple threads use same HttpClient object

2007-10-18 Thread Roland Weber
Puneet Lakhina wrote:
> On 10/18/07, Roland Weber <[EMAIL PROTECTED]> wrote:
>> Puneet Lakhina wrote:
>>>  public void run() {
>>>
>>> HttpClient client = new HttpClient();
>>> PostMethod postMethod  = new PostMethod(sameURL);
>>> /*Set parameters in post method*/
>>> client.executeMethod();
>>>  /*Do something with the response*/
>>> postMethod.releaseConnection();
>>> }
>> This will leak a connection for every request, until they
>> are released by garbage collection.
> 
> 
> Isnt postMethod.releaseConnection() done to prevent that??

Sorry, my wording was misleading. I should have written
"until they are closed by garbage collection". To release is
not to close, as you will learn from the "Connection Persistence"
section of the Performance Tuning Guide:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/performance.html

cheers,
  Roland


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



Re: Should Multiple threads use same HttpClient object

2007-10-18 Thread Roland Weber
Puneet Lakhina wrote:
>  public void run() {
> 
> HttpClient client = new HttpClient();
> PostMethod postMethod  = new PostMethod(sameURL);
> /*Set parameters in post method*/
> client.executeMethod();
>  /*Do something with the response*/
> postMethod.releaseConnection();
> }

This will leak a connection for every request, until they
are released by garbage collection.

> I am a little confused as to how the connection management takes place.
> Should i be using the same HttpClient object across different threads?
> Should I be in that case using the MultiThreadedConnectionManager?

Yes and yes. You are looking for the Threading Guide:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/threading.html

hope that helps,
  Roland

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



Re: URI bug in HttpClient 3.1 Stable ?

2007-10-14 Thread Roland Weber
hefeng wrote:

> new URI("/action/getTicket?ticketNo=dced6ca9fd63f916e4b5d||786")

That constructor is deprecated because it was ambiguous. Use
"new URI(String, boolean)" and pass false as the second argument
to tell the URI class that it is supposed to escape the query string.

> I didn't research too deeply on this problem,

Looking into the JavaDocs would have saved you some time...
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/URI.html

cheers,
  Roland


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



Re: error connecting to HTTPS avax.net.ssl.SSLHandshakeException: unknown certificate

2007-10-12 Thread Roland Weber
Hello Mark,

> I'm not sure how I can obtain the HTTPS cert from the address I'm
> connecting to and place it in the keystore.  For example when a browser
> connects, it automatically receives the cert from the HTTPS address and does

Check if your browser allows to export the certificates.
Or maybe not-yet-commons-ssl can read the browser certificate store.

> so without prompting if it is (the cert) signed by an appropriate / trusted
> CA such as verisign and prompts when it's not signed as such.  The question
> I've got is either 1. how to obtain that cert and import,

See above, try with the browser first. Or else you hack some Java
code that opens an SSL connection and follows the certificate
chain, fetching and saving the certificates along the way.

> or 2. configure
> the Java code so that it automatically accepts the cert.

You've found the instructions for doing that when you followed
the link to our SSL guide which I posted previously.

cheers,
  Roland


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



Re: error connecting to HTTPS avax.net.ssl.SSLHandshakeException: unknown certificate

2007-10-07 Thread Roland Weber
Mark Dundon wrote:
> 
> unknown certificate

Isn't that error message self-explanatory? Import the
certificate required for the site you are connecting to.

http://jakarta.apache.org/httpcomponents/httpclient-3.x/sslguide.html
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/keytool.html

Or use a dedicated certificate store and nyc-ssl:
http://www.juliusdavies.ca/commons-ssl/

cheers,
  Roland



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



Re: Problem with Vista

2007-10-03 Thread Roland Weber
Hello,

first of all, please upgrade to HttpClient 3.1 final.
HttpClient 2 hasn't been supported for years.

The specific problem seems to be in the JDK code rather
than in HttpClient. We've had Windows problems because
of IPv6 support being enabled (not Vista though). Check
your network settings and make sure you can connect to
the target server from other programs. Check whether
there are any know JVM bugs on your platform. Finally,
verify proxy settings. Maybe the JVM is trying to use
proxies set in the OS. You'll find discussions about
that in the mailing list archives.

cheers,
  Roland


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



Re: HTTP Response contains headers last

2007-09-27 Thread Roland Weber
Hi Chris,

> Good point!  I'll ask the folks who own the API that I'm accessing to
> move the record count and other API-specific status information to the
> HTTP response footers.  That seems like a reasonable request.  What do
> you think my chances are? ;)

Whoever had that idea in the first place has not the
least clue about protocol design... it's like arguing
architecture with someone who's understanding of a
house is "four walls and a roof":
- Eh, Sir... the roof goes on top.
- Says who? I need protection against creeping cold
  on the floor, so I put the roof at the bottom. Ha!

I guess your best chances are to suggest that the record count is
not put into headers or trailers, but added as the last line of
the message body. There, the application can parse it out.
Trailers are non-trivial to implement, and your folks seem to
use a hand-crafted implementation... I cannot imagine that any
standard HTTP implementation would even allow to send the body
before the entity.

If you can't convince them, the best way to make it work is
still HttpClient. You can install a custom socket factory. And
in your custom socket implementation, you can just buffer the
whole response and then deliver it to the caller in the correct
order: response line, headers, empty line, entity.

good luck,
  Roland

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



Re: HTTP Response contains headers last

2007-09-27 Thread Roland Weber
Hi Morris,

> I'm working on a workaround using the HttpURLConnection (java.util.net)
> class.  It's probably no where near as elegant or bullet proof as
> HttpClient, but at least I have direct access to the input stream so
> that I can parse it myself.

You don't. At least not with the public API. HttpURLConnection
will also automatically read in the head section. That's necessary
to determine whether there is a body in the first place, and to
evaluate the transfer encoding. If the transfer encoding is "chunked",
HttpURLConnection installs a layered stream that takes care of
decoding the chunks, just as HttpClient does.

> If you're interested, the server actually sends the headers last on
> purpose.  Reason being, it includes a header field containing a record
> count.

A guy called Peter Jackson once shot a movie called "Braindead".
Readers of this mail are welcome to decide for themselves whether
this remark is off-topic. The movie is funny, by the way. If you
like splatter.

RFC 2616, that is HTTP 1.1, explicitly allows for footers (or
rather trailers) in section 3.6.1 and elsewhere. These have to
be properly announced in the headers, and can only be used in
combination with chunked encoding. They might get lost by proxies.
But no proxy would relay what your server is sending anyway.

If folks have to invent their own data format, they should just
do so. Instead of pretending to "tweak" a standard. How is any
receiver supposed to reliably detect the end of the entity with
this ? They have to scan the input, and then they might
as well count the records themselves while scanning. *shiver*

> I don't think it's worth all the trouble that this has caused
> me.  I'd much rather make a second API call to get the record count then
> have to deal with this, but, that's the way it is for now!

Sincere condolences,
  Roland


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



Re: HTTP Response contains headers last

2007-09-27 Thread Roland Weber
Hello Chris,

that server is not only sending the headers last.
It is sending the whole head section of the HTTP
response after the body. That is not HTTP at all.
Not even close.
Even though the supposed body is listed in the
output as "headers", that's not what HttpClient
makes of it. HttpClient simply skips garbage
lines at the beginning of a response, until it
finds the line starting with "HTTP/1.1". Then,
it reads in the head section. And then, it would
try to read the body, except that there is none.
There is not even the required empty line that
terminates the head section.

I have two explanations for this. One: the server
is using persistent connections, but gets confused
by something the client does. That could happen if
you use the SimpleHttpConnectionManager from multiple
threads. But if that log is the full log of a test
run, that's not what happens.
Two: the server is totally screwed and has no idea
of what HTTP specifies. In that case, you're best
off by connecting directly to the server using a
Socket. I'm sorry, but that behavior is way too far
off to tweak HttpClient into tolerance.

cheers,
  Roland

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



Re: Using MultiThreadedHttpConnectionManager in a Servlet

2007-09-27 Thread Roland Weber
Hello Josh,

Josh Fix wrote:
> Is it possible to have multiple threads from my servlet
> open simultaneous connections to an external web site with
> different requests and read the results?
Sure. That's what the MultiThreadedHttpConnectionManager
is there for.
> I would really like to get around the blocking aspect of
> the read statements.

What are your settings for the connections-per-host and
total-connections limits? Default for CPH is 2, as that
is mentioned in RFC 2616. Since you're operating some
kind of proxy agent, you are entitled to use 2 per client
for which your servlet is acting.
http://jakarta.apache.org/httpcomponents/httpclient-3.x/threading.html

> My servlet declares the MTHCM as a static object in the
> servlet class, so that once instance is shared amongst all
> incoming servlet requests, and a static{} block is used in
> the class to set timeouts/etc.

Bad style, but probably irrelevant for the problem at hand.
You should declare shared objects as non-static attributes of
the servlet and initialize them in the Servlet.init() method.

> The HttpClient is newed in the doGet method.

Unless you need different parameters for the instances,
that is not a good idea. Use one client object and set
specific parameters at the method you are executing.
Our preferences hierarchies do not respond well to using
multiple clients with the same MTHCM. There can be only
one parent to the connection manager params.

hope that helps,
  Roland


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



Re: HTTP Response contains headers last

2007-09-27 Thread Roland Weber
Morris, Chris wrote:
> I'm working with an API that returns the HTTP Response Headers after the
> response body.  This confuses the HTTPClient and PostMethod into
> thinking that there is no body.

We have code to handle footers in ChunkedInputStream. However,
this is the first time that I encounter footers in the wild,
so maybe that code is buggy. Could you please post a wire log,
including headers and content? Feel free to obfuscate any
sensitive information and cut the contents.
http://jakarta.apache.org/httpcomponents/httpclient-3.x/logging.html

> Is there a way for me to get direct
> access to the response input stream so that I can parse it out myself?

You can hack through the code of course. The socket's stream
is not accessible directly, because the ChunkedInputStream has
to parse the "chunked" encoding. Trailers are only allowed with
chunked encoding. If you have to hack through the code anyway,
you should rather fix what is broken than work around what is
already there.

> The information contained in this communication is
> confidential, and is intended only for the sole use of
> the recipient named above. [...]

Always funny to read these footers on mails sent to public
mailing lists...

cheers,
  Roland


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



Re: HTTP/1.1 401 Unauthorized xxx

2007-09-25 Thread Roland Weber
Christian Chitão Teixeira wrote:
> In fact, the only difference is that in the first, the scope could be wrong 
> or something..
> The second the scope is not specified...

Yes, scoping has potential for causing problems.
If you want to use preemptive authentication,
you'll have to use unscoped credentials anyway.

cheers,
  Roland


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



Re: HTTP/1.1 401 Unauthorized xxx

2007-09-25 Thread Roland Weber
Christian Chitão Teixeira wrote:
> Problem solved...
> 
Glad to hear that. It would have been nice to add an explanation
how you've solved it, for others that run into the same problem.

> Another issue:
> Is it possible to "create" a webservice not based on a wsdl URL, but in a 
> wsdl in memory?

I'm afraid you're on the wrong list. This one is about HttpClient.
Maybe the WebServices folks can help you out:
http://ws.apache.org/mail.html

cheers,
  Roland


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



Re: how to turn off the console output

2007-09-21 Thread Roland Weber
Yang Sun wrote:
> Is there anyway to turn off the console output?

Configure your logging framework correctly:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/logging.html

cheers,
  Roland


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



Re: How to set proxy information in httpClient object from browser

2007-09-21 Thread Roland Weber
Hello Nitya,

> in the implementation they say that you need to write this...
> 
> Protocol stricthttps = new Protocol( "https", new
> StrictSSLProtocolSocketFactory(true), 443);
>  HttpClient client = new HttpClient();
>  client.getHostConfiguration().setHost("hostname", 443, stricthttps);
> 
> Now this Factory implementation stops the man in the middle attack... by
> verifying the hostName... TRUE passed in its constructor..
> 
> But doesnt it mean that it should also call this classes' createSocket()
> method??? because that method has the method verifyHostName() which should
> be called so that hostname is verified???

When SSL connections are tunnelled through a proxy, there is
first a plain HTTP connection to the proxy. That's what you've
made to work now. Subsequently, a tunnel to the target is
established, and the SSL connection with protocol "https"
is layered on top of that. You don't have to verify a hostname
for the connection to the proxy.
> 
> By implementing the above code I see that the createSocket() method of
> StrictSSLProtocolSocketFactory class doesnt get called.. why is that??? or i
> m missing something here

Have a look at HttpConnection.tunnelCreated, that's where
the SSL connection is layered on top of the tunnel.

If you have specific SSL questions, you should also consider
posting them to the nyc-ssl mailing list:
http://www.juliusdavies.ca/commons-ssl/

hope that helps,
  Roland



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



Re: How to set proxy information in httpClient object from browser

2007-09-19 Thread Roland Weber
nitya vyas wrote:
> i m using 2.0 but the code is same..

No it's not. Upgrade! 2.0 has been unsupported for an eternity.

> in 3.1 also i will have isSecure() and
> isProxied() true because i want https and proxy server both...

Yes.

> So that
> means that DefaultProtocolSocketFactory will get initialized and not the
> other one..

No it doesn't. Look at the code fragment I quoted:

>> if (isSecure() && isProxied()) {
>> Protocol defaultprotocol = Protocol.getProtocol("http");
>> socketFactory = defaultprotocol.getSocketFactory();
>> } else {
>> socketFactory = this.protocolInUse.getSocketFactory();
>> }

The factory is obtained from a protocol, which is *registered*
under the name "http". You can register _your_own_ protocol with
that name, and then _your_ socket factory is used.

Let me know when you have upgraded to 3.1.
Until then, don't expect me to help you out.

cheers,
  Roland


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



Re: host change ip

2007-09-19 Thread Roland Weber
ttitfly wrote:
> my problem is:
>   
>   when the host change new  ip ,the httpclient will spider by the old ip.

That's not HttpClient. It's the JVM that caches IP addresses.
Please consult the JVM documentation to see what you can do
about it. This has also been mentioned on one of our mailing
lists, not too long ago.

cheers,
  Roland



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



Re: Uploading a File using Http clien

2007-09-19 Thread Roland Weber
bhadu wrote:
> Look at my code...First servlet...
> 
> 
>String urlString = "http://localhost:8787//testone//MyServlet";;
>   
>   
>   HttpClient client = new HttpClient();
>   PostMethod postMethod = new PostMethod(urlString);
>   post(postMethod);

So here you are setting the entity of the POST method
to a multipart entity.

>   client.getParams().setParameter("http.useragent", "My Browser");
>   postMethod.addParameter("test","testvalue");
>   NameValuePair[] nm = {new NameValuePair("test","test")};
>   postMethod.setRequestBody(nm);

And here you replace that with "test=test".

An entity _is_ the request body. You can have only one.

cheers,
  Roland

>   int statusCode1 = client.executeMethod(postMethod);
>   System.out.println(" status >>> "+statusCode1);
>   System.out.println("statusLine>>>" + 
> postMethod.getStatusLine());
>   postMethod.releaseConnection();
>   
> 
>   }
> 
>   private void post(PostMethod postMethod) throws FileNotFoundException
>   {
>File f = new File("C:\\error.txt");
>System.out.println("file exit = "+f.exists());
>   Part[] parts = {
> new FilePart(f.getName(), f)
> };
>   
> postMethod.addRequestHeader("Content-type","multipart/form-data;boundary="+f.length());
>   postMethod.addRequestHeader("content-disposition","form-data;
> name="+f.getName());
>   postMethod.setRequestEntity(
> new MultipartRequestEntity(parts, postMethod.getParams())
> );
>   }
> 


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



Re: How to set proxy information in httpClient object from browser

2007-09-19 Thread Roland Weber
nitya vyas wrote:
> The problem I find now is that this createSocket method does not get called
> from the HTTPConnection class... the reason being this line of code.(i
> dont wanna change the HTTPConnection if theres another way.. )
> 
> final ProtocolSocketFactory socketFactory = (isSecure() && isProxied()? new
> DefaultProtocolSocketFactory() : protocolInUse.getSocketFactory());
> 

What version of HttpClient are you using?
This is what I find in the current code (3.1 final):

if (isSecure() && isProxied()) {
Protocol defaultprotocol = Protocol.getProtocol("http");
socketFactory = defaultprotocol.getSocketFactory();
} else {
socketFactory = this.protocolInUse.getSocketFactory();
}

So you can simply register your own protocol "http"
that calls an instance of your socket factory.

cheers,
  Roland


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



Re: getting sessino id from a cookie

2007-09-16 Thread Roland Weber
Dmitry Beransky wrote:
> Hi,
> 
> Is there the best of a preferred way to parse a session id from a cookie
> header?
> I could just run this trough a regexp, but I've been wondering if there is
> something in the httpclient api that will do that for me already with a
> simple call like Header.getCookieValue("JSESSIONID").

Not quite, because HttpClient doesn't need to access cookie values.
The way to go is:

[1] - take all cookies you've collected
[2] - select the one you're interested in
[3] - get it's value

hope that helps,
  Roland

[1]
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpState.html#getCookies()
[2]
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/cookie/CookieSpec.html#match(java.lang.String,%20int,%20java.lang.String,%20boolean,%20org.apache.commons.httpclient.Cookie[])
[3]
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/NameValuePair.html#getValue()

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



Re: User-Agent

2007-09-16 Thread Roland Weber
It is not deprecated:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpMethod.html#setRequestHeader(org.apache.commons.httpclient.Header)
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpMethod.html#setRequestHeader(java.lang.String,%20java.lang.String)

While we are working on replacing HttpClient 3.x,
the new codebase is not ready to take over, and will
not be for months to come. The current stable release
we recommend for production use is HttpClient 3.1.

cheers,
  Roland

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



Re: Info about list

2007-09-16 Thread Roland Weber
Based on the information I am able to extract from this
thread, I believe it is spam. Just in case it is not...

>>> I just want the information or u'r provided FaQ (is anywhere)..about the
>>> httpclient-user list...

There is no FAQ about the httpclient-user list
(that I know about). There are some general pages
about mailing lists on Jakarta:

http://jakarta.apache.org/site/mail.html
http://jakarta.apache.org/site/mail2.html

The former has relevant links to this:

http://www.catb.org/~esr/faqs/smart-questions.html#bespecific
http://www.catb.org/~esr/faqs/smart-questions.html#writewell
http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
http://www.catb.org/~esr/faqs/smart-questions.html#homework

We have two FAQs and a primer in the HttpClient Wiki:

http://wiki.apache.org/jakarta-httpclient/FrontPage

cheers,
  Roland

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



Re: How to set proxy information in httpClient object from browser

2007-09-14 Thread Roland Weber
nitya vyas wrote:
> I found out that the problem lies in only one line ..
> 
> System.setProperty("java.net.useSystemProxies","true");
> 
> if i dont do this, the server will respond. or if i immediately write
> System.setProperty("java.net.useSystemProxies","false"); after that line
> only nothng in between then only it works and server responds..

Implement a ProtocolSocketFactory [1].
Use the Socket(Proxy) constructor [2]
with argument Proxy.NO_PROXY [3], then
connect. Mark Claassen did that before [4].

hope that helps,
  Roland

[1]
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.html
[2]
http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#Socket(java.net.Proxy)
[3] http://java.sun.com/j2se/1.5.0/docs/api/java/net/Proxy.html#NO_PROXY
[4]
http://mail-archives.apache.org/mod_mbox/jakarta-httpclient-user/200701.mbox/[EMAIL
 PROTECTED]

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



Re: Premature EOF on socket read

2007-08-31 Thread Roland Weber
Hello Henrich,

> Subsequently no IOException is thrown. My reading of
> http://www.mail-archive.com/httpclient-user@jakarta.apache.org/msg03923.html
>  was that one can assume that the entire resource was downloaded when EOF
> is encountered. Now I wonder how/where this situation should be handled?

Theoretically? Yes. If all components adhere to HTTP.
In your case, either the server or proxy don't.

> One thought is that ContentLengthInputStream is in a position to know and
> could throw some kind of premature EOF encountered exception.

That's how it is implemented in HttpCore-4.0. Unfortunately,
HttpClient 3.1 does not check the actual length received.
You can do that in your application however.

> Presumably the default retry logic would then retry such a request.

It wouldn't. By the time you start reading the response entity,
HttpClient.executeMethod has already returned and can therefore
not repeat the request.
> 
> Or should this be handled by the application?

Exactly.

hope that helps,
  Roland


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



Re: HttpClient fails with Unauthorized exception with reverse proxy

2007-08-31 Thread Roland Weber
Hello Sri,

you should find our Authentication Guide helpful:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/authentication.html

Make sure you know _what_ authentication mechanism the
proxy requires, and to supply the appropriate type of
credentials. In particular, NTLM authentication requires
NTCredentials.

cheers,
  Roland

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



Re: How to set proxy information in httpClient object from browser

2007-08-31 Thread Roland Weber
Thank you for reading the mailing list guidelines.[1] They link
to [2], which has a section "If You Can't Get An Answer"[3] that
might interest you.

nitya vyas wrote:
> Hi there,
> I am using a single HTTPClient object (static) for the desktop application
> with different method objects (get,post,multipartpost) for each call..I
> have also implemented StrictSSLSocketFactory implementation (SSL) for that
> httpClient object. Now i m suppose to get the proxy information from the
> default browser
Have a look at the proxy section of our Application Design FAQ:
http://wiki.apache.org/jakarta-httpclient/FrequentlyAskedApplicationDesignQuestions

I'm not sure that any of these methods will give you the proxy settings
of the default browser reliably, but you might get the operating system
settings on Windows (which are the IE settings) if you are using a 5.0
or newer JVM. If that is not sufficient, you probably have to contact
other forums to learn how to obtain the default browser settings.

> and set the proxy for all requests. I believe it must be
> done for the same static httpClient object for my app

That is correct. httpClient.getHostConfiguration().setProxy(...)
should do the trick, assuming that you don't pass an explicit
HostConfiguration when executing the methods.

hope that helps,
  Roland

[1] http://jakarta.apache.org/site/mail.html
[2] http://www.catb.org/~esr/faqs/smart-questions.html
[3] http://www.catb.org/~esr/faqs/smart-questions.html#id272290

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



Re: Set Session Attribute?

2007-08-31 Thread Roland Weber
[EMAIL PROTECTED] wrote:
> One of them relies on a session attribute having being set.  I'm having 
> problems figuring out how to do this? When we were mocking things, we
> used Spring's MockHTTPServletRequest and could call 
> getSession().setAttribute() on it.

ServletRequest is on the server.
HttpClient is on a client.

> How can I do this with HTTPClient?

You can't. Write servlet initialization code.

Is there something I am missing?

cheers,
  Roland


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



Re: Setting default cookie policy

2007-08-31 Thread Roland Weber
keith chapman wrote:
> Yes it can be done using httpMethod.getParams (This neeeds to be dont
> everytimr I send a request). But I want to set this once (system wide), not
> for each and every invocation.

I suggested that you set the parameter on the _client_,
not on the _method_. You need to set the parameter on the
client only once, it will apply to all methods that do
not override the value.
Based on the additional information you posted to the
developer list, I assume you don't have access to the
client either. Have a look at DefaultHttpParamsFactory
and DefaultHttpParams.setHttpParamsFactory.

cheers,
  Roland

> On 8/29/07, Roland Weber <[EMAIL PROTECTED]> wrote:
>> Hello Keith,
>>
>> set the cookie policy ID in the client parameters:
>>
>> http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html#COOKIE_POLICY
>>
>> You'll have to use CookiePolicy.BROWSER_COMPATIBILITY or
>> the new RFC_2965 to handle domains without the dot prefix.
>> RFC 2109 explicitly disallowed those, and that is the
>> default cookie policy.
>>
>> hope that helps,
>>   Roland
>>
>>
>> -
>> 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: BasicHttpContext

2007-08-31 Thread Roland Weber
Hello Rob,

please post user questions to httpclient-user@jakarta.apache.org
The commits list is _exclusively_ for messages generated by the
source code repository.
The samples in the SVN repository compile against trunk, which
has changed since the last release. Use the samples in
core-4.0-alpha5-src.

cheers,
  Roland

nysalsa nysalsa wrote:
> Hi, I've downloaded httpcomponents-core-4.0-alpha5.jar and tried to compile 
> the basic http server example obtaining an error related to the absence of 
> the class BasicHttpContext.
> I found it in the svn repository, but the question is: "Am I missing 
> something, or is it just a building problem of the downloaded jar or 
> something else?".
> Thanks for any advice.
>  
> Rob
> _
> Scarica GRATIS la versione personalizzata MSN di Internet Explorer 7!
> http://optimizedie7.msn.com/default.aspx?mkt=it-it


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



Re: Setting default cookie policy

2007-08-29 Thread Roland Weber
Hello Keith,

set the cookie policy ID in the client parameters:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html#COOKIE_POLICY

You'll have to use CookiePolicy.BROWSER_COMPATIBILITY or
the new RFC_2965 to handle domains without the dot prefix.
RFC 2109 explicitly disallowed those, and that is the
default cookie policy.

hope that helps,
  Roland


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



Re: release connection issue

2007-08-26 Thread Roland Weber
lior grinfeld wrote:
> the question is: why the line with method.releaseConnection does nothing

It does exactly what it's supposed to do: it puts the
connection back into the pool, keeping it open for re-use.
This has been discussed numerous times, please search the
mailing list archives.

cheers,
  Roland


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



Re: Long Upload

2007-08-22 Thread Roland Weber
Raymond Kroeker wrote:
> I am using the HttpPut method in conjunction with a RequestEntity to
> upload large files.  Is there a way to determine if the network connection
> is broken partially through the upload?

None that I know of. Java should throw an IOException if the
connection is broken. Some platforms might try to re-establish
the network connection before signaling communication errors
to applications.

cheers,
  Roland

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



Re: Detecting lost network connection?!

2007-08-20 Thread Roland Weber
Hi Michael,

> I'm receiving a file via HTTP-GET and then simply
> disconnect the computer from the internet. My program stops receiving
> anything but does not throw a SocketTimeoutException or something
> similar although I've set all (?) the necessary parameters on the
> HttpClient and GetMethod (please see sample code below!).

The actual read operation on the socket calls somewhere into
native code. If the TCP/IP subsystem of your machine and/or
of the JVM you are using does not detect the lost connection
and trigger an error, then HttpClient can do nothing about it.
Have you checked whether other users of the Mac JDK have
reported similar problems, not necessarily with HttpClient?

> I thought that something like
> client.getHttpConnectionManager().closeIdleConnections(1); would do
> the job but it doesn't.

A connection that is allocated by your application is not idle.
Idle connections are those that have been returned by applications.

A workaround would be to start a second thread that monitors
the application and calls method.abort() if the download stalls.
Check the stack trace of the exception that is triggered to see
where exactly the thread was blocked.

> client.getHttpConnectionManager().getParams().setSoTimeout(5000);
> client.getParams().setSoTimeout(5000);
> get.getParams().setSoTimeout(5000);

Doesn't look like you missed one.

cheers,
  Roland


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



Re: Fw: question about RequestEntity

2007-08-17 Thread Roland Weber
[EMAIL PROTECTED] wrote:
> Thanks for response,  I put log in the code, It seems from httpclient, I 
> send whole string in right character set encoding, but when I retireve it 
> from server side,  it's messed up, do you have any idea?
> 
> req.getInputStream().read(buf);

Check the return value of InputStream.read(byte[]).

cheers,
  Roland


PS: You might also want to have a look at item 4 here:
http://www.catb.org/~esr/faqs/smart-questions.html#forum

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



Re: entity.getContentLength() and entity.getContent() don't match

2007-08-11 Thread Roland Weber
Hello Nadeem,

InputStreamEntity is an outgoing entity. It's meant for
sending messages, not for receiving. You've got the
input stream from the response entity, just read from
the stream and write that data into a file.

hope that helps,
  Roland

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



Re: While using Heritrix its shows me warning about logging

2007-08-10 Thread Roland Weber
Please read our logging guide:
http://jakarta.apache.org/commons/httpclient/logging.html

cheers,
  Roland

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



Re: Size-Limitations with PUT through Proxy

2007-08-10 Thread Roland Weber
Clemens Eisserer wrote:

> PutMethod putMethod = new PutMethod(upLoadURL);
> putMethod.setDoAuthentication(true);
> putMethod.setRequestBody(new
> FastByteArrayInputStream(payLoad));   
> server.getHttpClient().executeMethod(putMethod);

I've never heard of FastByteArrayInputStream. Is this some
Java 6 stuff? setRequestBody is deprecated. Since you've
got the data already, use the ByteArrayRequestEntity.

> The code works quite well without a
> proxy in between.

Maybe the proxy doesn't support PUT request correctly?
Have you tried POST instead?

Consider sending us a wire log:
http://jakarta.apache.org/commons/httpclient/logging.html


cheers,
  Roland

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



Re: Http KeepAlive simulation

2007-08-10 Thread Roland Weber
You don't need to simulate keep-alive. HttpClient does
it for real. Just make sure that you use only one
instance of HttpClient for sending your requests.

http://jakarta.apache.org/commons/httpclient/performance.html#Connection_persistence

cheers,
  Roland

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



Re: How can I set the http request header in the GetMethod of http client

2007-08-10 Thread Roland Weber
ying lcs wrote:
> How can I set the http request header in the GetMethod of http client?

What about GetMethod.setRequestHeader("name", "value")?
It's in the HttpMethod interface. There are also
addRequestHeader(...) methods for multi-valued headers.

cheers,
  Roland


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



Re: newbie question - setContentChunked

2007-08-10 Thread Roland Weber
tvomalley wrote:
> I have this code to post a SOAP message:

Have you taken a look at the PostSOAP example?
http://svn.apache.org/repos/asf/jakarta/httpcomponents/oac.hc3x/trunk/src/examples/PostSOAP.java

> PostMethod post = new PostMethod(myurl);
> post.setRequestHeader(HttpFields.__Accept, "application/soap+xml");
> post.setRequestHeader(HttpFields.__UserAgent, "MyClient");
> post.setRequestHeader(HttpFields.__ContentType, "text/xml; charset=utf-8");
> post.setRequestHeader("SOAPAction", "\"\"");
> post.setRequestEntity(new InputStreamRequestEntity(new
> ByteArrayInputStream(message),
> InputStreamRequestEntity.CONTENT_LENGTH_AUTO));
> post.setContentChunked(true);
> 
> Is that all I have to do?

I don't see anything missing.

Why do you wrap a ByteArrayInputStream around the
message? We have a ByteArrayRequestEntity.
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/ByteArrayRequestEntity.html
Passing the content type to the constructor will
make the setRequestHeader for the content type
above superfluous.

> How do I set the size?

You don't. It is determined from the entity.

hope that helps,
  Roland


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



Re: redirected URL causing URIException

2007-08-06 Thread Roland Weber
ranadheer solleti wrote:
> Will you issue a fix for this in the near future.

No, we will not issue a fix.

cheers,
  Roland


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



Re: During the Post operation doFormUrlEncode in EncodingUtil is called twice.

2007-08-06 Thread Roland Weber
Bala mani wrote:
> Hi during Post opeartion,
>the doFormUrlEncode function of EncodingUtil class is called twice.

Are you calling postMethod.getRequestEntity() from your application?
It is the only call I could find where the request entity is not
cached in an attribute once it's generated.

Please file a bug report in JIRA:
https://issues.apache.org/jira/browse/HTTPCLIENT

cheers,
  Roland


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



Re: No Exception occurs and Timeout doesnt work .. helpp ..

2007-08-06 Thread Roland Weber
Hello Albert,

> client.getHttpConnectionManager().getParams().setConnectionTimeout(1);

this is the inverse case to HTTPCLIENT-671:
https://issues.apache.org/jira/browse/HTTPCLIENT-671

cheers,
  Roland

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



Re: Multipart post error

2007-08-06 Thread Roland Weber
> Thanks for replying so fast. How do you deal the uploaded file on
> server?

Please have a look at the Application Design FAQ, section 1.3:
http://wiki.apache.org/jakarta-httpclient/FrequentlyAskedApplicationDesignQuestions#head-a68ea7b135b89a75e548f38ac562cf97a31ce64f

cheers,
  Roland


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



Re: URL to HttpUtil problem in http tunelling

2007-08-03 Thread Roland Weber
Hello Albert,

> how to get
> the java object from the servlet using HttpUtil. I hope it's just as 
simple
> as :
> 
> InputStream in = method.getResponseBodyAsStream();
> BufferedInputStream bin = new BufferedInputStream(in);
> ObjectInputStream objIn = new ObjectInputStream(bin);
> GZIPInputStream gzipIn = new GZIPInputStream(objIn);
> Object object = objIn.readObject();

Leave out the gzip part, or decompress between buffered and
object input stream. But basically, yes, that's how it works.

> I dont know how to send a java object to a remote
> servlet. I know it has something to do with the
> PostMethod.setRequestEntity.. And i've seen the implementations of
> RequestEntity like
> InputStreamRequestEntity, FileRequestEntity, StringRequestEntity, but
> there's no ObjectRequestEntity or something.

RequestEntity is an interface. Implement the ObjectRequestEntity
yourself, it's not that hard. I think this has also been discussed
on one of the mailing lists before.

hope that helps,
  Roland



smime.p7s
Description: S/MIME Cryptographic Signature


Re: redirected URL causing URIException

2007-08-03 Thread Roland Weber
Hello Ranadheer,

> Hi, The query part of the redirected URL
> (http://www.frontpagemagazine.com/Articles/Read.aspx?GUID={1643A1FE-10FB
> -467C-B335-05AF12113C7A}
>  FB-467C-B335-05AF12113C7A%7d> )  is causing a URIException.
> 
> 
> Is there any way we can configure HttpClient to allow additional
> characters or a code change is the only way out?

There is no way to configure. You can either modify the HttpClient code,
or you disable automatic redirects and process the redirect URL in your
application.

hope that helps,
  Roland



smime.p7s
Description: S/MIME Cryptographic Signature


Re: Per thread logging

2007-08-01 Thread Roland Weber
Hi Oleg,

> Why do not you simply use Log4J or similar logging toolkit to output the
> name of the thread that generated the logging event?

The environment has several hundred threads. You don't want to enable
output from several hundred threads and figure out later which of these
is the relevant one. The performance of the server would collapse
immediately.
Furthermore, the requests for a single user will be served by different
threads over time. What you need for this scenario is a way to enable
logging selectively, based on some attribute in the user session.
This cannot be handled by simply configuring a logging toolkit.

> In my opinion this kind of functionality falls into the responsibility
> of the underlying logging toolkit, not HttpClient

It's the responsibility of the application and the logging framework,
yes. But if HttpClient can offer a simple way to achieve the result
without ThreadLocal hacks, then why not? Getting a logger name from
the parameters instead of using a hardcoded one in certain situations
is not an unreasonable change. "Certain situations" are cases where
a long-living object with a logger is created, such as an instance
of the Wire class.
The situation will be simplified when we get rid of static logger
instances (HTTPCLIENT-668). Then, a custom log factory can supply a
thread-specific logger instance. Still, getting the logger name from
parameters is even simpler. Or would be, if connection pooling
didn't interfere with per-thread settings. That's something to be
considered for timeouts and buffer sizes, too.

cheers,
  Roland


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



Re: Per thread logging

2007-08-01 Thread Roland Weber
Hi Lars,

>> We've frozen the API. Contrib seems like a better place.
> 
> With such a change, how would that go into contrib? Just asking, since
> this is more a patch, then anything else, right? So in contrib, how
> would that be presented?

As a patched Wire class, with instructions: copy this source file
and update the package name to replace the Wire class that ships
with the distribution.

cheers,
  Roland


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



Re: Strange Exception: host parameter is null

2007-07-31 Thread Roland Weber
Hi Ryan,

> the fourth  method trigger a Exception: host parameter is null. 

Please post a stack trace of this exception. Without that,
we can only guess where you are seeing the problem.

> the first three are work properly, only the fourth got a exception.Below is 
> the PostData function
> public String PostData(String url, NameValuePair[] data) {
>   PostMethod post = new PostMethod(url);

What value has 'url' here? Is it an absolute URL?

cheers,
  Roland


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



Re: Per thread logging

2007-07-31 Thread Roland Weber
Lars George wrote:
> I have since then amended
> Wire to hold an optional thread-local field of a logger that I hand in
> using the setParameter() of the HttpClient (or HttpState etc.). If the
> logger is set as a parameter, it is assigned to the per-thread
> (thread-local) logger field of Wire and in turn used during logging
> output. Works like a charm.
> 
> Anyone thinks this is a good idea?

The idea is good. I don't like the idea of a logger object in
the parameters though. Have you considered to put the _name_ of
the logger into the parameters and let Wire perform the lookup?
That's what I was planning for http-dispatch while I was still
working on it. Actually, I meant to allow a name in the params
and an object in the context, but the latter is a 4.0 concept.

It is also possible to solve this without touching the API at all,
by using a logger implementation that keeps a ThreadLocal itself.
But changing Wire is surely simpler.

> Should it go into the main code or

We've frozen the API. Contrib seems like a better place.

> should I keep "extending" the code with every updated version?

I expect exactly one more updated version: 3.1 final.

> If you like I can provide patches for my changes.

As mentioned above, for contrib it would be welcome.
Just open a feature request in JIRA and attach a patch.

thanks and cheers,
  Roland

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



Re: Still getting socket closed exception

2007-07-30 Thread Roland Weber
Hello Saurabh,

> java.net.SocketException: Socket closed
> at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)

This looks like some kind of SSL handshake problem,
and we're really not SSL specialists on this list.
Have you tried to enable SSL debug messages?
http://java.sun.com/j2se/1.4.2/docs/guide/security/jsse/JSSERefGuide.html#Debug

hope that helps,
  Roland



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



Re: can i send ssl request with AES ciphersuite ?

2007-07-30 Thread Roland Weber
Hello,

> can i send ssl request with AES ciphersuite ? and how?
> can i import new ciphers? and how?

This is a mailing list about HttpClient. To some degree,
we also address non-HttpClient questions that are somehow
related to HTTP or HTTPS. But selecting a ciphersuite in
an SSL handshake is off-topic. Please locate a mailing
list about SSL or JSSE and post your questions there.

cheers,
  Roland

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



Re: Problem with slow servlet-response over Proxy

2007-07-29 Thread Roland Weber
Clemens Eisserer wrote:
> Since it works without proxy and I also can fetch ordinary html-files
> using exactly the same code over proxy I guess the proxy does kill my
> request because no data is traveling home for too long time.
> 
> Could this be true?

Yes. It's called a timeout. If you want to simulate a slow server,
you can send small pieces of the payload, for example a single byte,
every few milliseconds. Then the connection should not time out.

hope that helps,
  Roland


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



Re: HttpClient: Session not accessible

2007-07-29 Thread Roland Weber
Hello Mansoor,

> the problem is i need user session (having information which i keep in the
> Session at the time of login)  for file uploading which i don't get when i
> post data through applet using HttpClient.

There's the problem: Applet. When you use HttpURLConnection, the
Java Plugin will pick up the cookies from the browser and send
them along with the request. HttpClient cannot do that, and so
your request is most likely missing the browser session cookie.

> During search i found the HttpState class ... but i don't understand how it
> will work in my case.

Here's a starting point for your searching the mailing list archives:
http://mail-archives.apache.org/mod_mbox/jakarta-httpclient-user/200608.mbox/[EMAIL
 PROTECTED]

That user already found a way to pass the cookie from
the browser/HTML page to the applet. Maybe the "how"
is mentioned in a previous discussion on the list.
This one also has a hint:
http://forum.springframework.org/showthread.php?t=14931

Good search terms for your problem should be "applet"
and "session cookie".

hope that helps,
  Roland

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



Re: using with httpclient ?

2007-07-29 Thread Roland Weber
Hello Sören,

>  action="/bop/ebp/app/billpresentment/exportprocessbans">
[...]
> NameValuePair action   = new NameValuePair("action",
> "/bop/ebp/app/billpresentment/exportprocessbans");

'action' is not a parameter name, omit it.

> How can I submit  data with  using httpclient?

It's explained in the primer, section "Analyze the Form":
http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners#head-93d017d102ea8a83b2ad6e07c5184ec2f922f09a

cheers,
  Roland


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



Re: Tool for parsing http request and response?

2007-07-27 Thread Roland Weber
Hello Jeroen,

> I need a tool (HttpClient?) to parse a String representation of a
> request and a response like exampled below into an object
> representation, so not actually perform the request (or response).

Please have a look at HttpCore (HttpComponents-Core base module):
http://jakarta.apache.org/httpcomponents/httpcomponents-core/
http://jakarta.apache.org/httpcomponents/httpcomponents-core/httpcore/apidocs/index.html

It has separate parser components. You can either try to use
the parser components directly, or you can implement a fake
"connection" that works only for receiving and uses the string
representations instead of opening a socket.

While it has stabilized recently, the core API is still alpha.
If you find roadblocks for your use case, you can suggest
changes to the API.

hope that helps,
  Roland



smime.p7s
Description: S/MIME Cryptographic Signature


  1   2   3   4   5   6   7   8   >