Proper Order of things...

2003-03-02 Thread Ross Rankin
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:

 

 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

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

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

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

e)   none of the above

 

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

 

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

 

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

 

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

 

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

 

 



Cookie Header String

2003-03-02 Thread Ross Rankin
I had a new problem today, but unlike my last one, I figured it out today.
But I was wondering if it the way the HttpClient works, a setting, or
something I should be doing.

The HttpClient is creating a header like this:

Cookie: cookie1=blah1

Cookie: cookie2=blah2

Cookie: cookie3-blah3

Cookie: cookie4=blah4

 

But the browser sends cookies like this:

Cookie: cookie1=blah1; cookie2=blah2; cookie3=blah3; cookie4=blah4

 

Right now I cam just getting the cookies and creating a response header with
the array concatenated into the above format and the server accepts it.  

Is there an easier way?

 

Ross



DO NOT REPLY [Bug 17569] - Include generated website in the distribution

2003-03-02 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17569.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17569

Include generated website in the distribution





--- Additional Comments From [EMAIL PROTECTED]  2003-03-02 22:38 ---
Well, AFAIK velocity + the jakarta-site2 stylesheet are sufficient to build 
the docs (i.e. maven is not really required).

The reason for this is, to be able to build an off-line or better local
version of the docs, where one is able to adapt all links to external sources
to its local dev doc site.

Getting the stuff from CVS is not really a good solution, since one
canĀ“t build the stuff in off-line mode and further the docs might not
correspond to the downloaded source package ...

Please have a look at the velocity build/build.xml file! It's really simple,
to add an anakia task, which is able to build docs even in the off-line mode
...

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



Re: Cookie Header String

2003-03-02 Thread Oleg Kalnichevski
Ross,
Just use strict mode. That will make HttpClient put all cookies into one
header
Oleg

On Sun, 2003-03-02 at 21:38, Ross Rankin wrote:
 I had a new problem today, but unlike my last one, I figured it out today.
 But I was wondering if it the way the HttpClient works, a setting, or
 something I should be doing.
 
 The HttpClient is creating a header like this:
 
 Cookie: cookie1=blah1
 
 Cookie: cookie2=blah2
 
 Cookie: cookie3-blah3
 
 Cookie: cookie4=blah4
 
  
 
 But the browser sends cookies like this:
 
 Cookie: cookie1=blah1; cookie2=blah2; cookie3=blah3; cookie4=blah4
 
  
 
 Right now I cam just getting the cookies and creating a response header with
 the array concatenated into the above format and the server accepts it.  
 
 Is there an easier way?
 
  
 
 Ross
 


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



Re: Proper Order of things...

2003-03-02 Thread Laura Werner
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]


Re: Proper Order of things...

2003-03-02 Thread Michael Becke
Ross,

Below are some answers to your questions.

 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

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

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

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

e)   none of the above
There are many options.  It depends what specifically your needs are.  
I generally only use a method once.  The only real restrictions are as 
follows:

1 - methods are not thread safe so they can only be used by one thread 
at a time
2 - a method must be recycled before it can be reused

2) If doing a Post which returns another page do I need to really Get 
that
page?
I'm not exactly sure what your asking, but, after you do a post, the 
server's response can be read using one of the getResponseBody*() 
methods.

3) What the proper place for a method.releaseConnection? After the 
method,
after you are all done?
The connection should be released after it is no longer being used.  A 
connection is given to a method each time it is executed.  So, the 
connection is no longer being used after a particular method execution 
and the corresponding response are completed.  It will most likely look 
something like:

try {
client.executeMethod(method);
// process method response here
} catch (Exception e ) {
// do something
} finally {
method.releaseConnection();
}

4) Once the client is set up and configured, do you need to do 
anything to
maintain it?
I can't think of anything.  I'm not sure what you mean by maintain 
though.

5) Rejected cookies.  OK so the system I'm connecting to can not make 
a good
cookie, can't I accept it anyway?
It is possible to change the cookie parsing policy to be more lenient.  
Try:

CookiePolicy.setDefaultPolicy(CookiePolicy.COMPATABILITY);

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
It should look something like:

	HttpClient httpClient = new HttpClient();
	httpClient.getHostConfiguration().setHost(jakarta.apache.org, -1, 
http);
	GetMethod method = new GetMethod(/);
	httpClient.executeMethod(method);
	
Please take a look at the examples directory for some more ideas of how 
HttpClient can be used.  The examples dir is included in the source and 
is also available at:

  http://cvs.apache.org/viewcvs/jakarta-commons/httpclient/src/examples/

Mike

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