class Gopher::Request

basic class for an incoming request

Attributes

input[RW]
ip_address[RW]
selector[RW]

Public Class Methods

new(raw, ip_addr=nil) click to toggle source
# File lib/gopher2000/request.rb, line 9
def initialize(raw, ip_addr=nil)
  @raw = raw
  @selector, @input = @raw.chomp.split("\t")
  
        @selector = Gopher::Application.sanitize_selector(@selector)
        @ip_address = ip_addr
end

Public Instance Methods

url() click to toggle source
# File lib/gopher2000/request.rb, line 21
def url
  @raw.chomp.split("\t").first.gsub(/^URL\:/, '')
end
url?() click to toggle source
# File lib/gopher2000/request.rb, line 17
def url?
  @raw =~ /^URL\:/
end
valid?() click to toggle source

confirm that this is actually a valid gopher request @return [Boolean] true if the request is valid, false otherwise

# File lib/gopher2000/request.rb, line 27
def valid?
  # The Selector string should be no longer than 255 characters. (RFC 1436)
  @selector.length <= 255
end