タグ

関連タグで絞り込む (2)

タグの絞り込みを解除

postに関するk1LoWのブックマーク (1)

  • 備忘録 [Ruby]net/httpでPOST

    net/httpを使用して、シンプルなPOSTからファイルのアップロードまで試してみました。 まずはシンプルなパターン。 require "net/http" require "uri" uri = URI.parse("http://www.mysample.com/index.php") Net::HTTP.start(uri.host, uri.port){|http| #ヘッダー部 header = { "user-agent" => "Ruby/#{RUBY_VERSION} MyHttpClient" } #ボディ部 body = "id=1&name=name" #送信 response = http.post(uri.path, body, header) } 次に、HTTPRequestのサブクラスであるNet::HTTP::Postを使用したパターン。 require

  • 1