Skip to content

Commit

Permalink
Moved the create_uuid in core.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Marin Usalj committed Jun 17, 2012
1 parent 0da77ef commit 79339ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
10 changes: 2 additions & 8 deletions motion/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def initialize(url, http_method = :get, options={})
@payload = options.delete(:payload)
#not tested
@files = options.delete(:files)
@boundary = options.delete(:boundary) || create_uuid unless @files.nil?
@boundary = options.delete(:boundary) || BW.create_uuid unless @files.nil?
#
@credentials = options.delete(:credentials) || {}
@credentials = {:username => '', :password => ''}.merge(@credentials)
Expand Down Expand Up @@ -167,7 +167,7 @@ def initiate_request(url_string)
@request.setHTTPMethod @method
@headers = {"Content-Type" => "multipart/form-data; boundary=#{@boundary}"} if !@files.nil? && @headers.nil?
@request.setAllHTTPHeaderFields(@headers) if @headers

# @payload needs to be converted to data
unless @method == "GET" || (@payload.nil? && @files.nil?)
@body = NSMutableData.data
Expand Down Expand Up @@ -299,12 +299,6 @@ def create_connection(request, delegate)
NSURLConnection.connectionWithRequest(request, delegate:delegate)
end

def create_uuid
uuid = CFUUIDCreate(nil)
uuid_string = CFUUIDCreateString(nil, uuid)
CFRelease(uuid)
uuid_string
end
end
end
end
1 change: 1 addition & 0 deletions spec/motion/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class WatchedObj; attr_accessor :test_value end
@cache_policy = 24234
@leftover_option = 'trololo'
@headers = { 'User-Agent' => "Mozilla/5.0 (X11; Linux x86_64; rv:12.0) \n Gecko/20100101 Firefox/12.0" }
# @files = [NSJSONSerialization.dataWithJSONObject({ fake: 'json' }, options:0, error:nil), NSMutableData.data]
@options = { action: @action,
payload: @payload,
credentials: @credentials,
Expand Down

0 comments on commit 79339ae

Please sign in to comment.