lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm trying to get a JPEG image through an http.request call, but when I look at the body, something in the chain has gone and changed all the 0A bytes to 0D0A, corrupting the image.

Example code:
-----

local http=require"socket.http"

local body, code, headers, status = http.request "http://rlv.zcache.com/lua_logo_tshirt-p235316434391085880z89ss_400.jpg";

local file = io.open("corrupt-jpeg.jpg",'w')
file:write(body)
file:close()

-----

You can open the file that outputs to see how it's being corrupted (and you can check that it's line-ending coercion in a hex editor).

Any ideas for how to fix?