Class: UU::OS::HTTP::HTTPPost

Inherits:
HTTPMethod show all
Defined in:
uu_os_connection-2.2.4/lib/uu/os/http/http_post.rb

Overview

POST Method.

Instance Attribute Summary

Attributes inherited from HTTPMethod

#headers, #method, #parameters, #path

Instance Method Summary (collapse)

Methods inherited from HTTPMethod

#set_header, #set_parameter

Instance Method Details

- (HTTPMethod) accept(*content_type)

Sets custom Accept header.

Parameters:

  • content_type (Array<String>)

    Accepted content-type.

Returns:

  • (HTTPMethod)

    Self instance for configuration chaining.



24
25
26
27
# File 'uu_os_connection-2.2.4/lib/uu/os/http/http_post.rb', line 24

def accept(*content_type)
  headers[:accept] = content_type
  return self
end

- (HTTPPost) content_type(content_type)

Defines content-type to be used for payload.

Parameters:

  • content_type (String)

    Content-type

Returns:

  • (HTTPPost)

    Self instance for configuration chaining.



32
33
34
35
# File 'uu_os_connection-2.2.4/lib/uu/os/http/http_post.rb', line 32

def content_type(content_type)
  headers[:content_type] = content_type
  return self
end

- (UU::OS::HTTP::HTTPResponse) execute(payload = nil)

Executes method sending given payload. In case you need to stream response or upload large data, execute_async should be used.

Parameters:

  • payload (Hash, Array, IO, String, Object) (defaults to: nil)

    Payload to be sent. If no content-type was set, Hash is automatically sent as multipart/form-data. If content-type was set as application/json, any object with exclusion of String and IO is transformed using #to_json method.

Returns:



42
43
44
# File 'uu_os_connection-2.2.4/lib/uu/os/http/http_post.rb', line 42

def execute(payload = nil)
  super(process_payload(payload))
end

- (UU::OS::HTTP::HTTPResponse) execute_async(payload = nil)

Executes method sending given payload asynchronously. Unlike execute, this call is non blocking.

Parameters:

  • payload (Hash, Array, IO, String, Object) (defaults to: nil)

    Payload to be sent. If no content-type was set, Hash is automatically sent as multipart/form-data. If content-type was set as application/json, any object with exclusion of String and IO is transformed using #to_json method.

Returns:



50
51
52
# File 'uu_os_connection-2.2.4/lib/uu/os/http/http_post.rb', line 50

def execute_async(payload = nil)
  super(process_payload(payload))
end