Module: UrlHandler
- Defined in:
- lib/nlp_toolz/helpers/url_handler.rb
Class Method Summary collapse
Class Method Details
.build_url(host, port, path, query) ⇒ Object
8 9 10 11 |
# File 'lib/nlp_toolz/helpers/url_handler.rb', line 8 def build_url(host, port, path, query) return URI::HTTP.build({:host => host, :path => path, :query => query}) if port.nil? return URI::HTTP.build({:host => host, :port => port, :path => path, :query => query}) unless port.nil? end |
.post_data(content, uri, content_type) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/nlp_toolz/helpers/url_handler.rb', line 14 def post_data(content,uri,content_type) post = Net::HTTP::Post.new(uri.request_uri,content_type) post.body = content.force_encoding("utf-8") uri_response = Net::HTTP.start(uri.host,uri.port) {|http| http.request(post)} uri_response end |