Ross Rankin wrote:

I am getting inconsistent results on a few things and I realized I really am
sort of parroting examples and really don't know the true order of things
when doing a series of connections.  So let me ask a few questions:

What sorts of inconsistent results?

1) If doing to of the same type of requests what is the correct method for
they type of action do I:

a) use two Method variables

This works.

b) use the same one with a recycle but cast it new again

What do you mean by "cast it new again"? Aside from that, this works; you can re-use HttpMethodMethod objects as long as you call recycle() first. After you call recycle(), the object is essentially "virgin" again, so you have to call setPath, re-set all of the headers, and so on.

c) use the same one without a recycle but cast it new

This won't work. You must call recycle() if you're going to re-use a HttpMethod object.

d) use the same one with a recycle but use setPath between executes

See the answer to b).

2) If doing a Post which returns another page do I need to really Get that
page?

No, if I understand the question correctly. If you're writing a browser-type application and the POST is a page-transition sort of POST, then the data for the new page/resource will be returned in the response to the POST. There's no need to follow it by a GET. Of course, someone *could* dream up a protocol layered on top of HTTP that required all POSTs to be followed by GETs, but I've never heard of one.

3) What the proper place for a method.releaseConnection? After the method,
after you are all done?

After you're finished reading from the method's input stream, I think. I'm not 100% sure about this one though, because this part of httpclient has changed a lot.

4) Once the client is set up and configured, do you need to do anything to
maintain it?


HttpClient isn't really a server that you "set up" or "configure". It's just a class library that you call. So I don't really understand the question.

5) Rejected cookies. OK so the system I'm connecting to can not make a good
cookie, can't I accept it anyway?


You can experiment with the "apache.commons.httpclient.cookiespec" system property. By default, HttpClient uses the RFC2109 cookie policy, which is fairly strict. If you set this property to "COMPATIBILITY", it will be more lenient and might accept the broken cookies from your server. See the code in org.apache.commons.httpclient.cookie.CookiePolicy for details.

6) Starting out, here the order I think is correct am I right?
a) create a host configuration
a) create a connection using that host config
b) use that connection to create a connection Manager
c) use that connection Manager to create a client
d) create a Method
e) execute that method using the host config and client


Close. You don't need to create a connection yourself. Just create a connection manager (probably a MultiThreadedHttpConnectionManager) and then use that to create an HttpClient. The connection manager will create the connections itself, as needed. Then you create methods and execute them using your host config and client.

Laura Werner

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



Reply via email to