BOUNDARY = "AaB03x"
def encode_multipartformdata(parameters = {})
ret = String.new
parameters.each do |key, value|
unless value.empty?
ret << "\r\n--" << BOUNDARY << "\r\n"
ret << "Content-Disposition: form-data; name=\"#{key}\"\r\n\r\n"
ret << value
end
end
ret << "\r\n--" << BOUNDARY << "--\r\n"
end
I got stuck for a while on the boundary syntax and the \r\n stuff, but
eventually it worked ok.
I just needed it to send some data to a RDF database that offers a HTTP
API channel. So, this only works for the simplest case. There are some
more complex variations, like uploading one or more files, setting
individual content types for each part, etc.
rgds
Dema
"Dema" <demetri...@gmail.com> offered: