Class: Cloudflare::KV::Wrapper

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/cloudflare/kv/wrapper.rb

Defined Under Namespace

Classes: OctetParser

Constant Summary collapse

APPLICATION_OCTET_STREAM =
"application/octet-stream"

Instance Method Summary collapse

Methods inherited from Wrapper

#process_response

Instance Method Details

#parser_for(response) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/cloudflare/kv/wrapper.rb', line 23

def parser_for(response)
	if response.headers["content-type"].start_with?(APPLICATION_OCTET_STREAM)
		OctetParser
	else
		super
	end
end

#prepare_request(request, payload) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/cloudflare/kv/wrapper.rb', line 13

def prepare_request(request, payload)
	request.headers.add("accept", APPLICATION_OCTET_STREAM)
	
	if payload
		request.headers["content-type"] = APPLICATION_OCTET_STREAM
		
		request.body = ::Protocol::HTTP::Body::Buffered.new([payload.to_s])
	end
end