Re: [Fwd: Re: replace request]

Paul Pazandak wrote:
> 
> > Hi Paul,
> >
> > ...
> > Can I write a perform() method in my filter to override superclass's
> > method? If so, is perform() method the only one to be overrided?
> >
> > Thanks,
> > Qiang
> 
> You can call perform() or something like it... Try:
> 
>     request.getManager().runRequest(newrequest);
You are right. Not this guy.

> 
>     request.getClient().processRequest(newrequest);
Neither this guy, because processRequest is a protect method of Client.

>     (or maybe
>       request.getClient().getServer().perform(newrequest);)
I tried this one. But it seems perform the newrequest failed, always
return Gateway Timeout message. I guess there must do sth. before
applying perform. Here is my code of filter:

	Request savedRequest;
    public Reply ingoingFilter(Request request) throws HTTPException
    {
	if (request is my signal)
	{
		try {
			Reply r = request.getClient().getServer().perform(savedRequest);
			return r;
		} catch (ClientException c)
		{
		}
	}
	return null;
    }

    public Reply outgoingFilter(Request request, Reply reply) 
    {
	if (request follows my condition)
	{
		savedRequest = request;
	}
    }

Here is the dumped savedRequest:
--
POST /pr/prLogin.asp HTTP/1.0
Proxy-Connection: keep-alive
Date: Thu, 19 Feb 1998 14:30:03 GMT
Cookie: ASPSESSIONID=VBZOFXJSJZIQJILG
Content-Length: 49
Content-Type: application/x-www-form-urlencoded
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Accept-Charset: iso-8859-1,*,utf-8
Accept-Language: en
Host: shubh.njit.edu
Referer: http://shubh.njit.edu/pr/prlogin.asp
User-Agent: Mozilla/4.03 [en] (Win95; I)
--
Of course this request has been performed successfully before. Here is
the exception message:
--
HTTP/1.1 504 Gateway Timeout
Date: Thu, 19 Feb 1998 14:40:19 GMT
Content-Length: 168
Content-Type: text/html
Server: 1.0beta
--

Thanks for your time,
Qiang

> 
> It depends upon which Request class you are using (there
> are two request classes). Look at the interface for Request.
> The first stmt is for w3c.www.protocol.http.request, the latter
> two are applicable to w3c.jigsaw.http.request. For a proxy filter
> I would suspect you are using the former.
> 
> Paul.
> 
> >
> >
> > Paul Pazandak wrote:
> > >
> > > I agree that your approach will not work.  What I had suggested
> > > is that you modify the request object. Your code simply reassigns
> > > a local attribute to reference a different object.
> > >
> > > What you need to do is use the interface of the Request object
> > > to modify the object itself, e.g.
> > >
> > > if (conditions) {
> > >     request.setURLPath(...)
> > > }
> > >
> > > Paul.
> > >
> > > Lv, Qiang wrote:
> > >
> > > > On Tue, 17 Feb 1998, Paul Pazandak wrote:
> > > >
> > > > >
> > > > > You should be able to simply modify the Request object and return it.
> > > > It seems I can not RETURN that Request object to Jigsaw core. I write my
> > > > filter's ingoingFilter method like this:
> > > >
> > > >         Request AnotherRequest;
> > > > public Reply ingoingFilter(Request request) {
> > > >         if (conditons) {
> > > >                 request = AnotherRequest;
> > > >         }
> > > >         return null;
> > > > }
> > > >
> > > > But the fact is Jigsaw did use the old request, instead of the new
> > > > AnotherRequest as its forward request. I think it is normal because that
> > > > request was passed to ingoingFilter just as an instance, what I did
> > > > within the ingoingFilter will not effect the outside request. Therefore
> > > > my following question araised.
> > > >
> > > > Thanks,
> > > > Qiang
> > > >
> > > > >
> > > > > Paul.
> > > > >
> > > > >
> > > > >
> > > > > Lv, Qiang wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I sucessfully set up Jigsaw as a proxy server. Now I can intercept
> > > > > > request from clients in my filter. I want to check these requests, then
> > > > > > replace some requests with mine in some conditions. The problem is:
> > > > > > ingoingFilter only get a instance of Request. How can I replace that
> > > > > > request with a new one and let Jigsaw forward my new request?
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > -------------------------------------------------
> > > > > > Qiang Lv
> >
> 
>    --
> 
> ********************************************************************
> Paul Pazandak                                      pazandak@objs.com
> Object Services and Consulting, Inc.             http://www.objs.com
> Minneapolis, Minnesota 55420-5409                       612-881-6498
> ********************************************************************

-- 
-------------------------------------------------
Qiang Lv
room 4220, ITC building
CIS department, NJIT
University Heights
Newark, NJ 07102
Tel: 973-596-2863(O)     973-596-2594(H)
Fax: 973-596-5777
------------------------------------------------

Received on Thursday, 19 February 1998 10:31:59 UTC