Method: Bio::Command.post_form
- Defined in:
- lib/bio/command.rb
.post_form(uri, params = nil, header = {}) ⇒ Object
Same as: Net::HTTP.post_form(uri, params) and it uses proxy if an environment variable (same as OpenURI.open_uri) is set. In addition, header can be set. (Note that Content-Type and Content-Length are automatically set by default.) uri must be a URI object, params must be a hash, and header must be a hash.
Arguments:
-
(required) uri: URI object or String
-
(optional) params: Hash containing parameters
-
(optional) header: Hash containing header strings
- Returns
-
(same as Net::HTTP::post_form)
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 |
# File 'lib/bio/command.rb', line 851 def post_form(uri, params = nil, header = {}) unless uri.is_a?(URI) uri = URI.parse(uri) end data = make_cgi_params(params) hash = { 'Content-Type' => 'application/x-www-form-urlencoded', 'Content-Length' => data.length.to_s } hash.update(header) start_http_uri(uri) do |http| http.post(uri.path, data, hash) end end |