I have a Lift application which generates a Gephi file on the fly. The Gehpi native format is XML based. The current plan is that the file gets downloaded and opened in Gephi on the client, without being processed/displayed in the browser.
I looked through the LiftResponse subclasses and it seems that either StreamingResponse or PlainTextResponse are likely to work (I already made a simple prototype with StreamingResponse). While there is a specialized JsonResponse, I don't see an XML specific response.
What are the advantages and disadvantages of picking one class over the other? Which is the more appropriate to use? Or are they equally good in this case?
Best How To :
PlainTextResponse are helpers that ultimately return an
InMemoryResponse. You can see the source code here and here respectively. You will notice that
PlainTextResponse sets a mimetype of "text/html" which is not necessarily correct for XML.
There is also an
XmlResponse type that you can investigate here and which might be what you are looking for. It too returns an
InMemoryResponse which as the name suggests, assumes your whole object is in memory before sending to the client.
StreamingResponse is more suitable for larger files and objects where it takes a Stream and reads chunks of that stream into memory and sends them, repeating that process until it is finished - so you don't need to keep the whole structure in memory.
Both should work for you, just a question of the size of data you are dealing with and how you are working with it otherwise.