use the Request.env hash (populated by the ThinParser) to determine whether this is a post blob operation. By definition, only get here with a body of
> 112kbytes - thin/lib/thin/request.rb:12 MAX_BODY = 1024 * (80 + 32)
# File lib/deltacloud/helpers/blob_stream.rb, line 187 def self.is_put_blob(request = nil) path = request.env['PATH_INFO'] method = request.env['REQUEST_METHOD'] if ( path =~ /^#{Regexp.escape(settings.root_url)}\/buckets/ && method == 'PUT' ) return true else return false end end
# File lib/deltacloud/helpers/blob_stream.rb, line 152 def initialize(request) @client_request = request @size = 0 bucket, blob = parse_bucket_blob(request.env["PATH_INFO"]) user, password = parse_credentials(request.env['HTTP_AUTHORIZATION']) content_type = request.env['CONTENT_TYPE'] || "" #deal with blob_metadata: (X-Deltacloud-Blobmeta-name: value) user_meta = BlobHelper::extract_blob_metadata_hash(request.env) @content_length = request.env['CONTENT_LENGTH'] @http, provider_request = driver.blob_stream_connection({:user=>user, :password=>password, :bucket=>bucket, :blob=>blob, :metadata=> user_meta, :content_type=>content_type, :content_length=>@content_length }) @content_length = @content_length.to_i #for comparison of size in '<< (data)' @sock = @http.request(provider_request, nil, true) end
# File lib/deltacloud/helpers/blob_stream.rb, line 168 def << (data) @sock.write(data) @size += data.length if (@size >= @content_length) result = @http.end_request if result.is_a?(Net::HTTPSuccess) @client_request.env["BLOB_SUCCESS"] = "true" else @client_request.env["BLOB_FAIL"] = result.body end end end
Generated with the Darkfish Rdoc Generator 2.