File: client.rb

package info (click to toggle)
ruby-em-http-request 1.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 628 kB
  • ctags: 243
  • sloc: ruby: 3,478; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 580 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$: << 'lib' << '../../lib'

require 'em-http'
require 'em-http/middleware/digest_auth'

digest_config = {
  :username => 'digest_username',
  :password => 'digest_password'
}

EM.run do

  conn_handshake = EM::HttpRequest.new('http://localhost:3000')
  http_handshake = conn_handshake.get

  http_handshake.callback do
    conn = EM::HttpRequest.new('http://localhost:3000')
    conn.use EM::Middleware::DigestAuth, http_handshake.response_header['WWW_AUTHENTICATE'], digest_config
    http = conn.get
    http.callback do
      puts http.response
      EM.stop
    end
  end
end