Archive for the ‘rails’ tag
curl POST data and newlines
I'm writing a Rails application for the microblogging strategy for Debian (which I used to call, debian-twitter, but you know how us Debian folks are
). I came up with a strange issue, that at first I thought was ActionController's fault or some crap.
So, I was testing one of my controllers with something like this:
cat /tmp/mm.txt | curl -d @- http://localhost:3000/message/new
/tmp/mm.txt is a PGP signed message which then I just send as POST data to my application. So far so good. However, when accessing the data from Rails, using request.body.read, I was a getting a single line, with the newlines (carriage returns) removed. So I started looking at how ActionController was getting the HTTP data and stuff. But then I tested:
cat /tmp/mm.txt | lwp-request -m POST http://localhost:3000/message/new
And that had the carriage returns in place.
So, I started looking at the curl man page and discovered this little gem:
–data-binary <data>
(HTTP) This posts data exactly as specified with no extra processing whatsoever.
If you start the data with the letter @, the rest should be a filename. Data is posted in a similar manner as –data-ascii does, except that newlines are preserved and conversions are never done.
If this option is used several times, the ones following the first will append data as described in -d/–data.
cat /tmp/mm.txt | curl --data-binary @- http://localhost:3000/message/new
…did indeed the tricky. Maybe someone needs this info some day.
Phusion Passenger™ on Debian
During DebConf9 I had the opportunity to work together with Señor Micah to try to bring Passenger back to shape and get it back to the NEW queue on Debian. We spent way too much time dealing with the build for the pkg-ruby-extras build model than to the actual fixing and updating. At the end we came up with a very well updated and DFSG-compatible (in contrast to the one that Brightbox provides, which isn't bad either to be honest) package for the 2.2.4 version.
Our current main interest was trying to get the package into Debian by cleaning up the licensing issues on some of the included files and try to come up with improvements in the near future (such as using Passenger directly from Nginx, instead of the Apache-only module). The future is bright and it'll bring sunshine to all of us.
Given that the package is still on the queue and there's a hell lot of other packages to be processed, you can grab the package here and if it fulfills your expectations, make sure you offer me and/or Micah a beer next time you see us around.



