[Lift] Re: Getting the file out of a Put Request..
Out of interest, can you elaborate on the bug? Cheers, tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Getting the file out of a Put Request..
On Wed, Feb 18, 2009 at 1:44 AM, Tim Perrett he...@timperrett.com wrote: Out of interest, can you elaborate on the bug? Req lazily builds a bunch of stuff the lazy parameter building is used during toString toString was being called after the request had been satisfied the underlying request.getContentType was being called Because the response had been sent, the request's content type was null. I strictly calculated the content type, but continue to lazily calculate the parameters. Cheers, tim -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Getting the file out of a Put Request..
Thanks for the explanation David. On Feb 18, 3:14 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Wed, Feb 18, 2009 at 1:44 AM, Tim Perrett he...@timperrett.com wrote: Out of interest, can you elaborate on the bug? Req lazily builds a bunch of stuff the lazy parameter building is used during toString toString was being called after the request had been satisfied the underlying request.getContentType was being called Because the response had been sent, the request's content type was null. I strictly calculated the content type, but continue to lazily calculate the parameters. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Getting the file out of a Put Request..
On Mon, Feb 16, 2009 at 1:53 PM, Alan M alan.morten...@gmail.com wrote: I'm still working away on my web service project (mentioned many months ago when I first lobbied to get Scala used) and we rely heavily on Put requests to create new resources. My first attempt involving Put and I've been stumped. I've been able to run the server (using mvn/jetty) and my webapp gets a PUT request (says so in the log produced by Jetty) and it does everything it's supposed to in my code, except it never gets the put file. I used curl to make the call and it shows the bar saying it's uploading the file and finishing. In the server code, the Reqs body is an Empty Box and it's uploadedFiles is an empty List. If you do a POST with the same data, does it work correctly (uploadedFiles gets populated)? So my question is, where do I get that data from? or is there something else I need to do to turn that feature on? (enable file upload or something?) Alan P.S. Something that might be relevant, since it's a webservice I'm using the stateless dispatcher.. does that effect how/when the paramCalculator works and therefore messes this up somehow? -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Getting the file out of a Put Request..
Would it not be because of: ServletFileUpload.isMultipartContent(request) // Req.scala line 79 If you then reference the commons lib, the source of that method looks like: public static final boolean isMultipartContent( HttpServletRequest request) { if (!post.equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); if (contentType == null) { return false; } if (contentType.toLowerCase().startsWith(MULTIPART)) { return true; } return false; } As DPP says, it looks as though you will *need* to make it a POST request, and also set the content type to multi-part. Alternatively, if, like me, you dont want to use overloaded post as its not very ROA, you can pass your entity body and just access the req.body property... you wouldnt get any of the useful lift helpers, but of course it depends on your use case :-) Cheers Tim On Feb 16, 10:05 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 1:53 PM, Alan M alan.morten...@gmail.com wrote: I'm still working away on my web service project (mentioned many months ago when I first lobbied to get Scala used) and we rely heavily on Put requests to create new resources. My first attempt involving Put and I've been stumped. I've been able to run the server (using mvn/jetty) and my webapp gets a PUT request (says so in the log produced by Jetty) and it does everything it's supposed to in my code, except it never gets the put file. I used curl to make the call and it shows the bar saying it's uploading the file and finishing. In the server code, the Reqs body is an Empty Box and it's uploadedFiles is an empty List. If you do a POST with the same data, does it work correctly (uploadedFiles gets populated)? So my question is, where do I get that data from? or is there something else I need to do to turn that feature on? (enable file upload or something?) Alan P.S. Something that might be relevant, since it's a webservice I'm using the stateless dispatcher.. does that effect how/when the paramCalculator works and therefore messes this up somehow? -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Getting the file out of a Put Request..
Sorry Alan, I assumed too much - my fault not yours. Generally, handling web services is done via dispatching. for instance: // Boot.scala LiftRules.dispatch.prepend { case r @ Req(some :: path :: Nil, , PutRequest) = () = myHandlerFunction(r) } def myHandlerFunction(req: Req): Box[LiftResponse] = { println(Entity Body is: + req.body.toString) ... } In this instance, you could pass the r property to the function and then do r.body to get the entire entity body. Make sense? If you wish to use lifts built in file uploading functions, you catogically cannot use PUT at this present time, you can only use POST with the accompanying content type set to multipart. Does that clear things up at all? Cheers, Tim On Feb 16, 10:58 pm, Alan M alan.morten...@gmail.com wrote: OK I think I follow up to a point.. so Lift needs to know that it's multipart to work correctly with a put, and it doesn't. That much I get, seems like Put is just broken. What I don't understand is that last bit though.. When you say: you can pass your entity body and just access the req.body property Where could you do that? I don't build the requests myself, so would I have to modify the Lift code to do this? Is there an extension point to make that happen? (like set request builder here or something and a class I can extend) Alan On Feb 16, 2:25 pm, Tim Perrett he...@timperrett.com wrote: Would it not be because of: ServletFileUpload.isMultipartContent(request) // Req.scala line 79 If you then reference the commons lib, the source of that method looks like: public static final boolean isMultipartContent( HttpServletRequest request) { if (!post.equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); if (contentType == null) { return false; } if (contentType.toLowerCase().startsWith(MULTIPART)) { return true; } return false; } As DPP says, it looks as though you will *need* to make it a POST request, and also set the content type to multi-part. Alternatively, if, like me, you dont want to use overloaded post as its not very ROA, you can pass your entity body and just access the req.body property... you wouldnt get any of the useful lift helpers, but of course it depends on your use case :-) Cheers Tim On Feb 16, 10:05 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 1:53 PM, Alan M alan.morten...@gmail.com wrote: I'm still working away on my web service project (mentioned many months ago when I first lobbied to get Scala used) and we rely heavily on Put requests to create new resources. My first attempt involving Put and I've been stumped. I've been able to run the server (using mvn/jetty) and my webapp gets a PUT request (says so in the log produced by Jetty) and it does everything it's supposed to in my code, except it never gets the put file. I used curl to make the call and it shows the bar saying it's uploading the file and finishing. In the server code, the Reqs body is an Empty Box and it's uploadedFiles is an empty List. If you do a POST with the same data, does it work correctly (uploadedFiles gets populated)? So my question is, where do I get that data from? or is there something else I need to do to turn that feature on? (enable file upload or something?) Alan P.S. Something that might be relevant, since it's a webservice I'm using the stateless dispatcher.. does that effect how/when the paramCalculator works and therefore messes this up somehow? -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Getting the file out of a Put Request..
I can understand why he wants to use PUT - its more resource orientated. I think we should stop talking about file uploads in the traditional sense, as the current lift design is doing the right thing for normal form based uploads.. However, lets talk about passing large entity bodies with web services and what *exactly* you are transfering and why. When im passing large bodies around in my web services, the binary content is usually passed as element content (base64 encoded) inside my XML body message as I might be passing some other meta-data such as name or whatever (in the case of an image). For example, my request body might look like: image namesome image/name data/data /image Where data include a base64 encoded image or whatever. This is of course an example, but you see how it can work? Thanks Tim On Feb 16, 11:10 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 2:58 PM, Alan M alan.morten...@gmail.com wrote: OK I think I follow up to a point.. so Lift needs to know that it's multipart to work correctly with a put, and it doesn't. That much I get, seems like Put is just broken. We are relying on the Apache multipart library to handle multipart uploads. The library conforms to RFC 1867 which only defines multipart file uploads for POSTs (not PUT, etc.) http://www.ietf.org/rfc/rfc1867.txt Are you writing your Lift app to a particular spec and if so, can you point us to that spec? Thanks, David What I don't understand is that last bit though.. When you say: you can pass your entity body and just access the req.body property Where could you do that? I don't build the requests myself, so would I have to modify the Lift code to do this? Is there an extension point to make that happen? (like set request builder here or something and a class I can extend) Alan On Feb 16, 2:25 pm, Tim Perrett he...@timperrett.com wrote: Would it not be because of: ServletFileUpload.isMultipartContent(request) // Req.scala line 79 If you then reference the commons lib, the source of that method looks like: public static final boolean isMultipartContent( HttpServletRequest request) { if (!post.equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); if (contentType == null) { return false; } if (contentType.toLowerCase().startsWith(MULTIPART)) { return true; } return false; } As DPP says, it looks as though you will *need* to make it a POST request, and also set the content type to multi-part. Alternatively, if, like me, you dont want to use overloaded post as its not very ROA, you can pass your entity body and just access the req.body property... you wouldnt get any of the useful lift helpers, but of course it depends on your use case :-) Cheers Tim On Feb 16, 10:05 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 1:53 PM, Alan M alan.morten...@gmail.com wrote: I'm still working away on my web service project (mentioned many months ago when I first lobbied to get Scala used) and we rely heavily on Put requests to create new resources. My first attempt involving Put and I've been stumped. I've been able to run the server (using mvn/jetty) and my webapp gets a PUT request (says so in the log produced by Jetty) and it does everything it's supposed to in my code, except it never gets the put file. I used curl to make the call and it shows the bar saying it's uploading the file and finishing. In the server code, the Reqs body is an Empty Box and it's uploadedFiles is an empty List. If you do a POST with the same data, does it work correctly (uploadedFiles gets populated)? So my question is, where do I get that data from? or is there something else I need to do to turn that feature on? (enable file upload or something?) Alan P.S. Something that might be relevant, since it's a webservice I'm using the stateless dispatcher.. does that effect how/when the paramCalculator works and therefore messes this up somehow? -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group,
[Lift] Re: Getting the file out of a Put Request..
Yeah but when I do the PUT, the req.body is an Empty box (no byte array). Also note, I'm using the statelessDispatch not dispatch.. but other than that, what you wrote code-wise is almost exactly one of the ways I tried. (the other way is to look at uploadedFiles instead of body) Alan On Feb 16, 3:08 pm, Tim Perrett he...@timperrett.com wrote: Sorry Alan, I assumed too much - my fault not yours. Generally, handling web services is done via dispatching. for instance: // Boot.scala LiftRules.dispatch.prepend { case r @ Req(some :: path :: Nil, , PutRequest) = () = myHandlerFunction(r) } def myHandlerFunction(req: Req): Box[LiftResponse] = { println(Entity Body is: + req.body.toString) ... } In this instance, you could pass the r property to the function and then do r.body to get the entire entity body. Make sense? If you wish to use lifts built in file uploading functions, you catogically cannot use PUT at this present time, you can only use POST with the accompanying content type set to multipart. Does that clear things up at all? Cheers, Tim On Feb 16, 10:58 pm, Alan M alan.morten...@gmail.com wrote: OK I think I follow up to a point.. so Lift needs to know that it's multipart to work correctly with a put, and it doesn't. That much I get, seems like Put is just broken. What I don't understand is that last bit though.. When you say: you can pass your entity body and just access the req.body property Where could you do that? I don't build the requests myself, so would I have to modify the Lift code to do this? Is there an extension point to make that happen? (like set request builder here or something and a class I can extend) Alan On Feb 16, 2:25 pm, Tim Perrett he...@timperrett.com wrote: Would it not be because of: ServletFileUpload.isMultipartContent(request) // Req.scala line 79 If you then reference the commons lib, the source of that method looks like: public static final boolean isMultipartContent( HttpServletRequest request) { if (!post.equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); if (contentType == null) { return false; } if (contentType.toLowerCase().startsWith(MULTIPART)) { return true; } return false; } As DPP says, it looks as though you will *need* to make it a POST request, and also set the content type to multi-part. Alternatively, if, like me, you dont want to use overloaded post as its not very ROA, you can pass your entity body and just access the req.body property... you wouldnt get any of the useful lift helpers, but of course it depends on your use case :-) Cheers Tim On Feb 16, 10:05 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 1:53 PM, Alan M alan.morten...@gmail.com wrote: I'm still working away on my web service project (mentioned many months ago when I first lobbied to get Scala used) and we rely heavily on Put requests to create new resources. My first attempt involving Put and I've been stumped. I've been able to run the server (using mvn/jetty) and my webapp gets a PUT request (says so in the log produced by Jetty) and it does everything it's supposed to in my code, except it never gets the put file. I used curl to make the call and it shows the bar saying it's uploading the file and finishing. In the server code, the Reqs body is an Empty Box and it's uploadedFiles is an empty List. If you do a POST with the same data, does it work correctly (uploadedFiles gets populated)? So my question is, where do I get that data from? or is there something else I need to do to turn that feature on? (enable file upload or something?) Alan P.S. Something that might be relevant, since it's a webservice I'm using the stateless dispatcher.. does that effect how/when the paramCalculator works and therefore messes this up somehow? -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Getting the file out of a Put Request..
Oh.. so I can stuff data in the body, even if the message is a PUT message? Not sure how to do that with curl without sending a bogus file along for the ride.. but if that's what you are saying then I guess that'd be acceptable. With the exception of some GIF/PNG/JPEG images now and again, the primary data will be XML files, some large some small. The primary sender will be a Javascript application making the webservice calls directly. Alan On Feb 16, 3:18 pm, Tim Perrett he...@timperrett.com wrote: I can understand why he wants to use PUT - its more resource orientated. I think we should stop talking about file uploads in the traditional sense, as the current lift design is doing the right thing for normal form based uploads.. However, lets talk about passing large entity bodies with web services and what *exactly* you are transfering and why. When im passing large bodies around in my web services, the binary content is usually passed as element content (base64 encoded) inside my XML body message as I might be passing some other meta-data such as name or whatever (in the case of an image). For example, my request body might look like: image namesome image/name data/data /image Where data include a base64 encoded image or whatever. This is of course an example, but you see how it can work? Thanks Tim On Feb 16, 11:10 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 2:58 PM, Alan M alan.morten...@gmail.com wrote: OK I think I follow up to a point.. so Lift needs to know that it's multipart to work correctly with a put, and it doesn't. That much I get, seems like Put is just broken. We are relying on the Apache multipart library to handle multipart uploads. The library conforms to RFC 1867 which only defines multipart file uploads for POSTs (not PUT, etc.) http://www.ietf.org/rfc/rfc1867.txt Are you writing your Lift app to a particular spec and if so, can you point us to that spec? Thanks, David What I don't understand is that last bit though.. When you say: you can pass your entity body and just access the req.body property Where could you do that? I don't build the requests myself, so would I have to modify the Lift code to do this? Is there an extension point to make that happen? (like set request builder here or something and a class I can extend) Alan On Feb 16, 2:25 pm, Tim Perrett he...@timperrett.com wrote: Would it not be because of: ServletFileUpload.isMultipartContent(request) // Req.scala line 79 If you then reference the commons lib, the source of that method looks like: public static final boolean isMultipartContent( HttpServletRequest request) { if (!post.equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); if (contentType == null) { return false; } if (contentType.toLowerCase().startsWith(MULTIPART)) { return true; } return false; } As DPP says, it looks as though you will *need* to make it a POST request, and also set the content type to multi-part. Alternatively, if, like me, you dont want to use overloaded post as its not very ROA, you can pass your entity body and just access the req.body property... you wouldnt get any of the useful lift helpers, but of course it depends on your use case :-) Cheers Tim On Feb 16, 10:05 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 1:53 PM, Alan M alan.morten...@gmail.com wrote: I'm still working away on my web service project (mentioned many months ago when I first lobbied to get Scala used) and we rely heavily on Put requests to create new resources. My first attempt involving Put and I've been stumped. I've been able to run the server (using mvn/jetty) and my webapp gets a PUT request (says so in the log produced by Jetty) and it does everything it's supposed to in my code, except it never gets the put file. I used curl to make the call and it shows the bar saying it's uploading the file and finishing. In the server code, the Reqs body is an Empty Box and it's uploadedFiles is an empty List. If you do a POST with the same data, does it work correctly (uploadedFiles gets populated)? So my question is, where do I get that data from? or is there something else I need to do to turn that feature on? (enable file upload or something?) Alan P.S. Something that might be relevant, since it's a webservice I'm using the stateless dispatcher.. does that effect how/when the paramCalculator works and therefore messes this up somehow? -- Lift, the
[Lift] Re: Getting the file out of a Put Request..
Alan, I'm modifying Lift. It turns out that it treated everything like application/x-www-form-urlencoded if there was not another handler. I'm changing the code so that if the submission is not marked with Content-Type application/x-www-form-urlencoded, you will have access to the post body. Give me 40 minutes to commit the change up. Thanks, David On Mon, Feb 16, 2009 at 3:28 PM, Alan M alan.morten...@gmail.com wrote: Oh.. so I can stuff data in the body, even if the message is a PUT message? Not sure how to do that with curl without sending a bogus file along for the ride.. but if that's what you are saying then I guess that'd be acceptable. With the exception of some GIF/PNG/JPEG images now and again, the primary data will be XML files, some large some small. The primary sender will be a Javascript application making the webservice calls directly. Alan On Feb 16, 3:18 pm, Tim Perrett he...@timperrett.com wrote: I can understand why he wants to use PUT - its more resource orientated. I think we should stop talking about file uploads in the traditional sense, as the current lift design is doing the right thing for normal form based uploads.. However, lets talk about passing large entity bodies with web services and what *exactly* you are transfering and why. When im passing large bodies around in my web services, the binary content is usually passed as element content (base64 encoded) inside my XML body message as I might be passing some other meta-data such as name or whatever (in the case of an image). For example, my request body might look like: image namesome image/name data/data /image Where data include a base64 encoded image or whatever. This is of course an example, but you see how it can work? Thanks Tim On Feb 16, 11:10 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 2:58 PM, Alan M alan.morten...@gmail.com wrote: OK I think I follow up to a point.. so Lift needs to know that it's multipart to work correctly with a put, and it doesn't. That much I get, seems like Put is just broken. We are relying on the Apache multipart library to handle multipart uploads. The library conforms to RFC 1867 which only defines multipart file uploads for POSTs (not PUT, etc.) http://www.ietf.org/rfc/rfc1867.txt Are you writing your Lift app to a particular spec and if so, can you point us to that spec? Thanks, David What I don't understand is that last bit though.. When you say: you can pass your entity body and just access the req.body property Where could you do that? I don't build the requests myself, so would I have to modify the Lift code to do this? Is there an extension point to make that happen? (like set request builder here or something and a class I can extend) Alan On Feb 16, 2:25 pm, Tim Perrett he...@timperrett.com wrote: Would it not be because of: ServletFileUpload.isMultipartContent(request) // Req.scala line 79 If you then reference the commons lib, the source of that method looks like: public static final boolean isMultipartContent( HttpServletRequest request) { if (!post.equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); if (contentType == null) { return false; } if (contentType.toLowerCase().startsWith(MULTIPART)) { return true; } return false; } As DPP says, it looks as though you will *need* to make it a POST request, and also set the content type to multi-part. Alternatively, if, like me, you dont want to use overloaded post as its not very ROA, you can pass your entity body and just access the req.body property... you wouldnt get any of the useful lift helpers, but of course it depends on your use case :-) Cheers Tim On Feb 16, 10:05 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 1:53 PM, Alan M alan.morten...@gmail.com wrote: I'm still working away on my web service project (mentioned many months ago when I first lobbied to get Scala used) and we rely heavily on Put requests to create new resources. My first attempt involving Put and I've been stumped. I've been able to run the server (using mvn/jetty) and my webapp gets a PUT request (says so in the log produced by Jetty) and it does everything it's supposed to in my code, except it never gets the put file. I used curl to make the call and it shows the bar saying it's uploading the file and finishing. In the server code, the Reqs body is an Empty Box and
[Lift] Re: Getting the file out of a Put Request..
On Mon, Feb 16, 2009 at 3:34 PM, Alan M alan.morten...@gmail.com wrote: I'm using maven for builds.. on .11-SNAPSHOT.. will this go there or will I have to switch over to building my own? It'll get built on Hudson and if you do a mvn -U, you'll get it. See http://scala-tools.org/hudson/job/lift/ When build 344 is complete, the change will be there for you. Alan On Feb 16, 3:31 pm, David Pollak feeder.of.the.be...@gmail.com wrote: Alan, I'm modifying Lift. It turns out that it treated everything like application/x-www-form-urlencoded if there was not another handler. I'm changing the code so that if the submission is not marked with Content-Type application/x-www-form-urlencoded, you will have access to the post body. Give me 40 minutes to commit the change up. Thanks, David On Mon, Feb 16, 2009 at 3:28 PM, Alan M alan.morten...@gmail.com wrote: Oh.. so I can stuff data in the body, even if the message is a PUT message? Not sure how to do that with curl without sending a bogus file along for the ride.. but if that's what you are saying then I guess that'd be acceptable. With the exception of some GIF/PNG/JPEG images now and again, the primary data will be XML files, some large some small. The primary sender will be a Javascript application making the webservice calls directly. Alan On Feb 16, 3:18 pm, Tim Perrett he...@timperrett.com wrote: I can understand why he wants to use PUT - its more resource orientated. I think we should stop talking about file uploads in the traditional sense, as the current lift design is doing the right thing for normal form based uploads.. However, lets talk about passing large entity bodies with web services and what *exactly* you are transfering and why. When im passing large bodies around in my web services, the binary content is usually passed as element content (base64 encoded) inside my XML body message as I might be passing some other meta-data such as name or whatever (in the case of an image). For example, my request body might look like: image namesome image/name data/data /image Where data include a base64 encoded image or whatever. This is of course an example, but you see how it can work? Thanks Tim On Feb 16, 11:10 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 2:58 PM, Alan M alan.morten...@gmail.com wrote: OK I think I follow up to a point.. so Lift needs to know that it's multipart to work correctly with a put, and it doesn't. That much I get, seems like Put is just broken. We are relying on the Apache multipart library to handle multipart uploads. The library conforms to RFC 1867 which only defines multipart file uploads for POSTs (not PUT, etc.) http://www.ietf.org/rfc/rfc1867.txt Are you writing your Lift app to a particular spec and if so, can you point us to that spec? Thanks, David What I don't understand is that last bit though.. When you say: you can pass your entity body and just access the req.body property Where could you do that? I don't build the requests myself, so would I have to modify the Lift code to do this? Is there an extension point to make that happen? (like set request builder here or something and a class I can extend) Alan On Feb 16, 2:25 pm, Tim Perrett he...@timperrett.com wrote: Would it not be because of: ServletFileUpload.isMultipartContent(request) // Req.scala line 79 If you then reference the commons lib, the source of that method looks like: public static final boolean isMultipartContent( HttpServletRequest request) { if (!post.equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); if (contentType == null) { return false; } if (contentType.toLowerCase().startsWith(MULTIPART)) { return true; } return false; } As DPP says, it looks as though you will *need* to make it a POST request, and also set the content type to multi-part. Alternatively, if, like me, you dont want to use overloaded post as its not very ROA, you can pass your entity body and just access the req.body property... you wouldnt get any of the useful lift helpers, but of course it depends on your use case :-) Cheers Tim On Feb 16, 10:05 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 1:53 PM, Alan M alan.morten...@gmail.com wrote:
[Lift] Re: Getting the file out of a Put Request..
Cool. That will make WebDAV and CalDAV support easier :) On 17/02/2009, at 10:38 AM, David Pollak wrote: On Mon, Feb 16, 2009 at 3:34 PM, Alan M alan.morten...@gmail.com wrote: I'm using maven for builds.. on .11-SNAPSHOT.. will this go there or will I have to switch over to building my own? It'll get built on Hudson and if you do a mvn -U, you'll get it. See http://scala-tools.org/hudson/job/lift/ When build 344 is complete, the change will be there for you. Alan On Feb 16, 3:31 pm, David Pollak feeder.of.the.be...@gmail.com wrote: Alan, I'm modifying Lift. It turns out that it treated everything like application/x-www-form-urlencoded if there was not another handler. I'm changing the code so that if the submission is not marked with Content-Type application/x-www-form-urlencoded, you will have access to the post body. Give me 40 minutes to commit the change up. Thanks, David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Getting the file out of a Put Request..
It appears that DPP is solving your issue now :-) However, for the record, I do exactly what you describe in terms of PUT / POST - this is a fairly normal ROA (but with objective-c clients, not javascript). FYI... if you have xml messages, you can access the xml automagically in your dispatching: req.xml_? // = boolean to check if its an xml body req.xml // = the actual xml passed (do whatever parsing) Not sure if im adding any value to this conversation - so please say if im just confusing you! REST services in lift is something I care about a lot and ensuring its correct is of great importance to me :-) Cheers, Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Getting the file out of a Put Request..
On Mon, Feb 16, 2009 at 4:34 PM, Alan M alan.morten...@gmail.com wrote: OK just to wrap up for me, because I didn't really follow all the implications of the change being made.. If I send a Put to a lift web service I should not be able to see the file content in the body of the Request? (now as in when the update is live/updated on my Maven) yes. And the code is live, so please do an mvn -U clean install and you should see the body of a PUT as long as the Content-Type is not form or multi-part. Alan On Feb 16, 3:47 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Feb 16, 2009 at 3:44 PM, Tim Perrett he...@timperrett.com wrote: It appears that DPP is solving your issue now :-) However, for the record, I do exactly what you describe in terms of PUT / POST - this is a fairly normal ROA (but with objective-c clients, not javascript). FYI... if you have xml messages, you can access the xml automagically in your dispatching: req.xml_? // = boolean to check if its an xml body req.xml // = the actual xml passed (do whatever parsing) Not sure if im adding any value to this conversation - so please say if im just confusing you! REST services in lift is something I care about a lot and ensuring its correct is of great importance to me :-) Tim, The Lift bug was that it was not respecting the Content-Type except in a few cases. The change is better all around and I believe will support any mime type with more flexibility. The current special case mime types are XML, multi-part mime, and forms. All other mime types will just pass the request body on the Req instance. This should make doing web services better in Lift. Thanks, David Cheers, Tim -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---