provide access to HttpServletRequest and HttpServletResponse from S #72

Closed
harryh opened this Issue Sep 23, 2009 · 8 comments

Comments

Projects
None yet
4 participants

harryh commented Sep 23, 2009

Title says it all. Sometimes we need access to the raw request/response objects

Member

mariusdanciu commented Sep 23, 2009

NO please don't do this !!!

It can be done today as:

S.containerRequest.map(r => (r.asInstanceOf[HTTPRequestServlet]).req)

Lift code should not hold explicit javax.servlet references outside of net.liftweb.http.provider.servlet package

harryh commented Sep 23, 2009

mariusdanciu: is there also a way to get the HttpServletResponse?

Member

mariusdanciu commented Sep 23, 2009

Lift by design hides HttpServletResponse and this is a very good thing. Lift represents responses as LiftResponse which has many subclasses, XmlResponse, JsonResponse, RedirectResponse etc.

You can still have access to servlet response from LiftRules

LiftRules.beforeSend.append {
case (liftResponse, httpResponse, _ ) => httpResponse.asInstanceOf[HTTPResponseServlet].resp
}

but before send is called right before sending the response to client. I'm not sure if this will be enough though.

Exposing HTTPResponse to S would open a gate for hacks, as people may use it to directly write things to outputstream ... and this will bypass Lifts processing pipeline. I think we should seriously discuss this on the public list

Br's,
Marius

Member

mariusdanciu commented Sep 23, 2009

You can us javax.servlet.http.HttpServletResponseWrapper to pass to the facebook library. Extending HttpServletResponseWrapper you can produce a LiftResponse that Lift would understand and this should be pretty straight forward

And this should not imply Lift changes.

Br's,
Marius

Member

mariusdanciu commented Sep 23, 2009

Closing the ticket.

Owner

dpp commented Sep 23, 2009

See http://groups.google.com/group/liftweb/browse_frm/thread/bbc8e000b64b8f8f?hl=en# for a description of how to access the raw request.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment