http://blog.sina.com.cn/s/blog_63eb3eec010179ex.html

本文摘自http://www.yaoxun.cc/?p=195


取得域名:

request.domain#=> zool.itrequest.domain(2) #=> blog.zool.it

取得子域名:
request.subdomain#=> "test.blog"request.subdomain(2) #=> "test"
request.subdomain#=> ["test","blog"] request.subdomain(2) #=> ["test"]

取得主机名:
request.host#=> "test.blog.zool.it"

取得带端口的主机名:
request.host_with_port#=> "test.blog.zool.it:3000"

代理服务器的主机名和端口:
request.raw_host_with_port#=> "test.blog.zool.it:3000"

取得由raw_host_with_port()获得的端口数值
request.port#=> 3000

取得raw_host_with_port()获得的端口文本字符串
request.port_string#=> ":3000"

取得当前使用网络协议
request.protocol#=> "http://"

取得网络协议
request.scheme#=> "http"

request
请求的uri地址
request.request_uri#=> "/posts/Hello-World"

取得由env['SERVER_PORT']返回的端口值
request.server_port#=> "3000"

当前是否在是用https加密协议
request.ssl?()#=> false

返回网络协议标准端口(http80,https443)
request.standard_port#=> 80

判断当前协议是否是标准端口
request.standard_port?#=> false

取得当前requset完整url
request.url#=> "http://test.blog.zool.it:3000/posts/Hello-World"

获取客户端ip
request.remote_ip



参考网址http://www.yaoxun.cc/