7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/apple-news/multipart_post_patch.rb', line 7
def build_head(boundary, name, filename, type, content_len, opts = {}, = {})
trans_encoding = opts["Content-Transfer-Encoding"] || "binary"
content_disposition = opts["Content-Disposition"] || "form-data"
part = ''
part << "--#{boundary}\r\n"
part << "Content-Disposition: #{content_disposition}; name=#{name}; filename=\"#{filename}\"; size=#{content_len}\r\n"
part << "Content-Length: #{content_len}\r\n"
if content_id = opts["Content-ID"]
part << "Content-ID: #{content_id}\r\n"
end
if ["Content-Type"] != nil
part << "Content-Type: " + ["Content-Type"] + "\r\n"
else
part << "Content-Type: #{type}\r\n"
end
part << "Content-Transfer-Encoding: #{trans_encoding}\r\n"
part << "\r\n"
end
|