2002-01-10 03:00:51 -05:00
|
|
|
#
|
2004-03-24 06:53:31 -05:00
|
|
|
# = uri/http.rb
|
2002-01-10 03:00:51 -05:00
|
|
|
#
|
2004-03-24 06:53:31 -05:00
|
|
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
|
|
|
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
|
|
|
# Revision:: $Id$
|
2002-01-10 03:00:51 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
require 'uri/generic'
|
|
|
|
|
|
|
|
module URI
|
|
|
|
|
2004-03-24 06:53:31 -05:00
|
|
|
#
|
2002-01-10 03:00:51 -05:00
|
|
|
# RFC1738 section 3.3.
|
2004-03-24 06:53:31 -05:00
|
|
|
#
|
2002-01-10 03:00:51 -05:00
|
|
|
class HTTP < Generic
|
|
|
|
DEFAULT_PORT = 80
|
|
|
|
|
|
|
|
COMPONENT = [
|
|
|
|
:scheme,
|
|
|
|
:userinfo, :host, :port,
|
|
|
|
:path,
|
|
|
|
:query,
|
|
|
|
:fragment
|
|
|
|
].freeze
|
|
|
|
|
2004-03-24 06:53:31 -05:00
|
|
|
#
|
|
|
|
# == Description
|
|
|
|
#
|
|
|
|
# Create a new URI::HTTP object from components of URI::HTTP with
|
|
|
|
# check. It is scheme, userinfo, host, port, path, query and
|
|
|
|
# fragment. It provided by an Array of a Hash.
|
|
|
|
#
|
2002-01-10 03:00:51 -05:00
|
|
|
def self.build(args)
|
|
|
|
tmp = Util::make_components_hash(self, args)
|
|
|
|
return super(tmp)
|
|
|
|
end
|
|
|
|
|
2004-03-24 06:53:31 -05:00
|
|
|
#
|
|
|
|
# == Description
|
|
|
|
#
|
|
|
|
# Create a new URI::HTTP object from ``generic'' components with no
|
|
|
|
# check.
|
|
|
|
#
|
2002-01-10 03:00:51 -05:00
|
|
|
def initialize(*arg)
|
|
|
|
super(*arg)
|
|
|
|
end
|
|
|
|
|
2004-03-24 06:53:31 -05:00
|
|
|
#
|
|
|
|
# == Description
|
|
|
|
#
|
|
|
|
# Returns: path + '?' + query
|
|
|
|
#
|
2002-01-10 03:00:51 -05:00
|
|
|
def request_uri
|
|
|
|
r = path_query
|
|
|
|
if r[0] != ?/
|
2004-03-24 06:53:31 -05:00
|
|
|
r = '/' + r
|
2002-01-10 03:00:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
r
|
|
|
|
end
|
2004-03-24 06:53:31 -05:00
|
|
|
end
|
2002-01-10 03:00:51 -05:00
|
|
|
|
|
|
|
@@schemes['HTTP'] = HTTP
|
2004-03-24 06:53:31 -05:00
|
|
|
end
|