how to get OutputStream - scala

I want to get an image from a response but I don't know how to get the OutputStream.
I know in jsp, it is:
response.getOutputStream()
but what is it in liftweb ?
Thanks a lot.

In Lift, there are very few cases (none that I can think of) where you need the outputStream.
If you are returning a composed HTML page, Lift's templating system takes care of collecting the HTML to send back to the browser.
If you are returning a response from a web service, you return a subclass of LiftResponse from your handler function, for example: XmlResponse(bar)
If you are streaming a file or something else, there's a special case LiftResponse: StreamingResponse
Please bring your question to the Lift community http://groups.google.com/group/liftweb/topics?hl=en and we can have a conversation about what your goal is and how to achieve that goal.
Thanks!

Related

Scala Play 2.5: Is it possible to bypass (defer) body parsing when using Action Composition?

I have several layers of ActionFunctions for api service, e.g. authorization and rate limiting. After implementing a file upload I realized that I'd really like authorization and rate limiting to happen before the file is uploaded, not after.
(I built a custom body parser for a file uploading, but let's say I have a giant json - why to parse it it's thrown away?)
Does anyone have an idea how to do it?
You can't do it with the ActionFunctions, as you said they use parsers to parse the body before the checks are done.
You can have checks before the parsing of the body by using EssentialAction. But you'll need to re-implement the logic of the compositions

Differences between a PortletRequest and a PortletResponse object

I understand that the Request objects (RenderRequest, ActionRequest, ...) contains the request we made, and the Response objects the response from the portlet...
But how, step by step everything works ?
If I take an example, I have a portlet with a little form. When I click onto the Send button, what is into the ActionRequest and the ActionResponse and when ? And after this first processing, what contains the RenderRequest and the RenderResponse objects?
Thanks for your help !
P.S: I don't use Spring MVC
I think the answer you seek is available in the JSR specs; either the old one (http://jcp.org/en/jsr/detail?id=168) or the new one (http://jcp.org/en/jsr/detail?id=286) depending on your environment.
The specs are free to download and give a fair overview of the concepts.

OpenRasta streaming response

Does anyone know if it is possible to write to the response stream in OpenRasta rather than returning an object as a response resource? Alternatively, am I able to implement an HTTP handler but still leverage OpenRasta's URL rewriting?
Thanks
Chris
You can always keep an http handler on the side to do specialized things, but that ties you to asp.net and will prevent your code from being portable on other hosts. If that's something you're ok with, any handler that's registered for a specific route will get executed before openrasta on asp.net.
that said, codecs are the ones writing to the response stream, so provided you have a custom IMediaTypeWriter you can write the resource instance on a stream whichever way you want.
Say for example that you returned an IEnumerable from your handler, as those get deferred executed, you can just start the enumeration of those in your custom codec without any problem.

modifying Zend_Soap_Server response

I want to modify the response that is sent when I am implementing a SOAP server using Zend_Soap_Server. I want to change the response that will be sent back because I am implementing the SOAP server for a client application that was written to work with another system but now I need to make it work with our system. The client application is expecting the XML response to be in a certain way. So what I want to do is that I dont want the handle method to put together its own XML response, I want to do it myself. Can this be done?
Thanks
I suspect there is some kind of output buffering trick you could use to do this, but a better solution might be to investigate the deeper cause of why the client is rejecting your XML and, in so doing, you may find a much more elegant solution.
For starters, you should probably read this very helpful article:
http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
You should then investigate Zend_Soap_AutoDiscover->setOperationBodyStyle() and Zend_Soap_AutoDiscover->setOperationBodyStyle() to see if changing the encoding style or binding style solves the problem.

iPhone: Load Queue on Startup

I've not found a answer to this question anywhere, but this seems like a typical problem:
I would like to send some POST-Requests (with ASIHTTPRequest, what I already do), but if something goes wrong, ther user can decide to "Try Later", that means, the task should be put on a queue and this queue should be read next time the application starts. So, that's my question: how to "save" the queue, so that the app can read it next time it starts? Is it possible to "read" the queue and try sending this POST-Request again, let's say, 10 min later, even if the application is not running?
What kind of documentation should I read in order to be able to do this?
I would be very glad to hear any answers. Thanks in advance.
P.S.: Another Idea I have: as I just have to Upload Photos, I could have a folder with all the Photos that still need to be uploaded, and when the App starts, the app looks at this folder and try to send all the photos in this folder. Does it make sense?
My approach for this issue would be like this:
Whenever you fail to send details - write content of the array to a file using '[NSArray writeToFile:]' you can use serialization if array contain any data which is custom defined (if your array contain standard cocoa objects(NSString,NSData etc) they already implemented with serialization )
When app launches; load the content from file directly to an array object ('[NSArray arrayWithContentsOfFile:]')
then construct http request and try sending. In application the data(in your case array) is stored/serialized not the request, you need to reconstruct the http request when you want to try one more time.(don't try serializing ASIHTTPRequest, you have reconstruct it)
I'm going to assume you've already looked at NSOperationQueue and NSOperation. AFAIK there is no built-in support for serializing NSOperation, but you could very easily write your own serialization mechanism for an NSOperation subclass that you use for posting data and write the an NSOperationQueue's operations to disk if something goes wrong.
Without knowing too many details it's hard to give a precise answer. There are many ways to write data to disk and load it again later, the direction you take will be largely dependent on your situation.