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_helper.rb, line 224 def self.is_put_blob(request = nil) path = request.env['PATH_INFO'] method = request.env['REQUEST_METHOD'] if ( path =~ %r^#{Regexp.escape(Deltacloud::API.settings.root_url)}\/buckets/ && method == 'PUT' ) return true else return false end end
# File lib/deltacloud/helpers/blob_stream_helper.rb, line 187 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 = Deltacloud::API.driver.blob_stream_connection({:user=>user, :password=>password, :bucket=>bucket, :blob=>blob, :metadata=> user_meta, :content_type=>content_type, :content_length=>@content_length, :context=>request }) @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_helper.rb, line 202 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" if BlobHelper.segmented_blob_op_type(@client_request) == "segment" @client_request.env["BLOB_SEGMENT_ID"] = Deltacloud::API.driver.blob_segment_id(@client_request, result) end else @client_request.env["BLOB_FAIL"] = result.body end end end
# File lib/deltacloud/helpers/blob_stream_helper.rb, line 218 def rewind end