Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleaned up the HTTP payload / files appending

  • Loading branch information...
commit fc1b3195d682fdc886f28276b641085209172488 1 parent c352ff6
@supermarin supermarin authored
Showing with 5 additions and 8 deletions.
  1. +5 −8 motion/http.rb
View
13 motion/http.rb
@@ -265,18 +265,16 @@ def append_payload(body)
end
def append_form_params(body)
- # puts "*** append_form #{@payload}"
if @payload.is_a?(String)
body.appendData(@payload.dataUsingEncoding NSUTF8StringEncoding)
else
list = process_payload_hash(@payload)
list.each do |key, value|
form_data = NSMutableData.new
- s = ""
- s += "\r\n" unless body.length == 0
- s += "--#{@boundary}\r\n"
+ s = "--#{@boundary}\r\n"
s += "Content-Disposition: form-data; name=\"#{key}\"\r\n\r\n"
s += value.to_s
+ s += "\r\n"
form_data.appendData(s.dataUsingEncoding NSUTF8StringEncoding)
body.appendData(form_data)
end
@@ -288,13 +286,12 @@ def append_form_params(body)
def append_files(body)
@files.each do |key, value|
file_data = NSMutableData.new
- s = ""
- s += "\r\n" unless body.length == 0
- s += "--#{@boundary}\r\n"
+ s = "--#{@boundary}\r\n"
s += "Content-Disposition: form-data; name=\"#{key}\"; filename=\"#{key}\"\r\n"
s += "Content-Type: application/octet-stream\r\n\r\n"
file_data.appendData(s.dataUsingEncoding NSUTF8StringEncoding)
file_data.appendData(value)
+ file_data.appendData("\r\n".dataUsingEncoding NSUTF8StringEncoding)
body.appendData(file_data)
end
@set_body_to_close_boundary = true
@@ -302,7 +299,7 @@ def append_files(body)
end
def append_body_boundary(body)
- body.appendData("\r\n--#{@boundary}--\r\n".dataUsingEncoding NSUTF8StringEncoding)
+ body.appendData("--#{@boundary}--\r\n".dataUsingEncoding NSUTF8StringEncoding)
end
def create_url(url_string)
Please sign in to comment.
Something went wrong with that request. Please try again.