Module: Ethon::Easy::Header
- Included in:
- Ethon::Easy
- Defined in:
- lib/ethon/easy/header.rb
Overview
This module contains the logic around adding headers to libcurl.
Instance Method Summary collapse
-
#compose_header(key, value) ⇒ String
Compose libcurl header string from key and value.
-
#header_list ⇒ FFI::Pointer
Return header_list.
-
#headers ⇒ Hash
Return headers, return empty hash if none.
-
#headers=(headers) ⇒ Object
Set the headers.
-
#set_headers ⇒ Symbol
Set previously defined headers in libcurl.
Instance Method Details
#compose_header(key, value) ⇒ String
Compose libcurl header string from key and value. Also replaces null bytes, because libcurl will complain about otherwise.
60 61 62 |
# File 'lib/ethon/easy/header.rb', line 60 def compose_header(key, value) Util.escape_zero_byte("#{key}: #{value}") end |
#header_list ⇒ FFI::Pointer
Return header_list.
33 34 35 |
# File 'lib/ethon/easy/header.rb', line 33 def header_list @header_list ||= nil end |
#headers ⇒ Hash
Return headers, return empty hash if none.
13 14 15 |
# File 'lib/ethon/easy/header.rb', line 13 def headers @headers ||= {} end |
#headers=(headers) ⇒ Object
Set the headers.
23 24 25 |
# File 'lib/ethon/easy/header.rb', line 23 def headers=(headers) @headers = headers end |
#set_headers ⇒ Symbol
Set previously defined headers in libcurl.
43 44 45 46 47 |
# File 'lib/ethon/easy/header.rb', line 43 def set_headers @header_list = nil headers.each {|k, v| @header_list = Curl.slist_append(@header_list, compose_header(k,v)) } Curl.set_option(:httpheader, @header_list, handle) end |