Class: OauthChina::Multipart::MultipartPost
- Inherits:
-
Object
- Object
- OauthChina::Multipart::MultipartPost
- Defined in:
- lib/oauth_china/multipart.rb
Constant Summary collapse
- BOUNDARY =
'tarsiers-rule0000'
- ContentType =
"multipart/form-data; boundary=" + BOUNDARY
Instance Method Summary collapse
Instance Method Details
#prepare_query(params) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/oauth_china/multipart.rb', line 50 def prepare_query(params) fp = [] params.each {|k,v| if v.respond_to?(:read) fp.push(FileParam.new(k, v.path, v.read)) v.close else fp.push(Param.new(k,v)) end } body = fp.collect {|p| "--" + BOUNDARY + "\r\n" + p.to_multipart }.join("") + "--" + BOUNDARY + "--\r\n" return body, ContentType end |
#set_form_data(req, params) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/oauth_china/multipart.rb', line 42 def set_form_data(req, params) body, content_type = prepare_query(params) req["Content-Type"] = content_type req.body = body req["Content-Length"] = body.bytesize req end |