>>You will need to authenticate first, which will most likely set a cookie.
Yes, i gave that a try, but i'm possibly doing something wrong (or not doing
something). I only got a session cookie using that url:
Initial set of cookies:
- session.ID=ID32f64093ff0d1c
Perhaps you can check it? This is the code I'm using (possibly something
missing as i was not sure of the sequence):
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT, "http");
client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);
client.getState().setCredentials(null, null, new
UsernamePasswordCredentials("xxx", "yyy"));
GetMethod authget = new GetMethod(args[0]);
client.executeMethod(authget);
System.out.println("Login form get: " +
authget.getStatusLine().toString());
Cookie[] initcookies = client.getState().getCookies(LOGON_SITE,
LOGON_PORT, "/", false);
System.out.println("Initial set of cookies:");
if (initcookies != null) {
if (initcookies.length == 0) {
System.out.println("None");
} else {
for (int i = 0; i < initcookies.length; i++) {
System.out.println("- " + initcookies[i].toString());
}
}
}
System.out.println(authget.getResponseBodyAsString());
authget.releaseConnection();
}
Constants are:
final static String LOGON_SITE = "www.racingpost.co.uk";
final static int LOGON_PORT = 80;
Thanks in advance.
Charles Johnson
On Saturday 03 January 2004 16:32 pm, you wrote:
> Hi Charles,
>
> It seems that this page is protected. You will need to authenticate
> first, which will most likely set a cookie. Once that is done you
> should be able to perform a get using the URL you've given.
>
> Mike
>
> On Jan 3, 2004, at 9:57 AM, Charles Johnson wrote:
> > Thanks Michael - that looks encouraging and I shall try it.
> >
> > First though, I'm a little concerned that the software may not be able
> > to do
> > what I want, as I've tried several approaches using the one-man code
> > fork
> > previously described, without any success. What I want to do is to be
> > able
> > to get onto this page:
> >
> > http://www.racingpost.co.uk/horses/?
> > MIval=v2_a_days_racing&day=04&month=Jan&
> > year=2004&flag=3
> >
> > which is (subject to parameter changes) a link in the menu called
> > 'Future
> > racing' at that page. Do you think this IS possible, and if so, how
> > should
> > it be done?
> >
> > Charles Johnson
> >
> > ----- Original Message -----
> > From: "Michael Becke" <[EMAIL PROTECTED]>
> > To: "Commons HttpClient Project"
> > <[EMAIL PROTECTED]>
> > Sent: Friday, January 02, 2004 10:07 PM
> > Subject: Re: DateParser pluggability
> >
> >> Hello,
> >>
> >> Date parser formats can be configured in the post 2.0 HttpClient code.
> >> This code, in CVS HEAD, is still pre-alpha but everything should still
> >> be working. You can add a format using something like the following:
> >>
> >> HttpParams params = DefaultHttpParams.getDefaultParams();
> >> HashSet patterns = new HashSet((Collection)
> >> params.getParameter(DateParser.KEY_DATE_PATTERNS));
> >> patterns.add("SOME_PATTERN");
> >> params.setParameter(DateParser.KEY_DATE_PATTERNS, patterns);
> >>
> >> Mike
> >>
> >> On Dec 31, 2003, at 10:57 AM, protean wrote:
> >>> I have had to supply an extra format String as follows:
> >>>
> >>> /** The patterns used for parsing dates */
> >>> private static final String[] DATE_PATTERNS = {
> >>> PATTERN_RFC1123,
> >>> PATTERN_RFC1036,
> >>> PATTERN_ASCTIME,
> >>> "EEE, dd-MMM-yyyy HH:mm:ss z",
> >>> "EEE, dd-MMM-yyyy HH-mm-ss z",
> >>> "EEE, dd MMM yy HH:mm:ss z",
> >>> "EEE dd-MMM-yyyy HH:mm:ss z",
> >>> "EEE dd MMM yyyy HH:mm:ss z",
> >>> "EEE dd-MMM-yyyy HH-mm-ss z",
> >>> "EEE dd-MMM-yy HH:mm:ss z",
> >>> "EEE dd MMM yy HH:mm:ss z",
> >>> "EEE,dd-MMM-yy HH:mm:ss z",
> >>> "EEE,dd-MMM-yyyy HH:mm:ss z",
> >>> "EEE, dd-MM-yyyy HH:mm:ss z",
> >>> // Extra for non-compliant site
> >>> "dd-MMM-yyyy HH:mm:ss zzz"
> >>> };
> >>>
> >>> to the DateParser class and produce my own build, as the DateParser
> >>> does not
> >>> seem to provide pluggability for non-compliant sites. Can anyone tell
> >>> me when
> >>> this situation may change so I no longer have to produce a one-man
> >>> code fork?
> >>>
> >>> C Johnson
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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]
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]