# Class: Asp::Response
[ "README", "lib/asp/server.rb", "lib/asp/application.rb", "lib/asp/request.rb", "lib/asp/response.rb", "lib/asp/session.rb", nil].each do
Asp.view_html
Asp::Session.view_html
Asp::Response.view_html
Asp::Application.view_html
Asp::Server.view_html
Asp::Request.view_html
Asp::Eval.view_html
end

Class Asp::Response < Object

(in files lib/asp/response.rb )

Copyright (C) 2003, 2004 Gregoire Lejeune <gregoire.lejeune@free.fr>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Methods

Public Class method: new( r, oAspError, aspHandler )

# File lib/asp/response.rb, line 362
    def initialize( r, oAspError, aspHandler )
      @oApacheRequest = r
      @oAspError = oAspError
      @oAspHandler = aspHandler

      @charset = "iso-8859-1"
      @contentType = "text/html"
      @expires = nil
      @expiresAbsolute = nil
      @bEnd = 0
      @hxHeader = Hash::new
      @hvCookies = Hash::new
    end

Public Instance method: addCacheItemDependencies( lCacheKeys )

Makes the validity of a cached item dependent on other items in the cache. (Not Implemented)

# File lib/asp/response.rb, line 217
    def addCacheItemDependencies( lCacheKeys )
      ## -> void
    end

Public Instance method: addCacheItemDependency( xCacheKey )

Makes the validity of a cached item dependent on another item in the cache. (Not Implemented)

# File lib/asp/response.rb, line 223
    def addCacheItemDependency( xCacheKey )
      ## -> void
    end

Public Instance method: addCookiesHeader()

# File lib/asp/response.rb, line 302
    def addCookiesHeader
      cookie_header = Array::new
      
      @hvCookies.each_key { |name| 
        value = Array::new
  
        #if name == "session-id"
        if name == Asp::Common::sessionID
          self.appendToLog( format( "You can't use %s for a cookie name since it is reserved for session management", Asp::Common::sessionID ) )
        else
          cookie = @hvCookies[name]
          cookie['Path'] ||= "/"
  
          cookie.each_pair { |k,v|
            case k.downcase
            when "expires"
              value[1] = "expires=#{v}"
            when "path"
              value[2] = "path=#{v}"
            when "domain"
              value[3] = "domain=#{v}"
            when "secure"
              value[4] = "secure"
            when "value"
              # we set the value later, nothing for now
            else
              if String( @hvCookies[name]['Value'].class ) != "String"
                if @hvCookies[name]['Value'].nil? == true
                  @hvCookies[name]['Value'] = Hash::new
                end
                @hvCookies[name]['Value'][k] = v
              end
            end
          }
 
          if String( @hvCookies[name]['Value'].class ) == "Hash"
            dict = Array::new
            @hvCookies[name]['Value'].each_pair { |k,v|
              dict.push( format( "%s=%s", Asp::Common::url_encode( k ), Asp::Common::url_encode( v ) ) )
            }
            value[0] = dict.join( "&" )
          else
            value[0] = Asp::Common::url_encode( @hvCookies[name]['Value'] )
          end
          value[0] = Asp::Common::url_encode( name )+"="+value[0]
          
          cookie = Array::new
          [0,1,2,3,4].each { |iCpt|
            next unless value[iCpt].nil? == false
            cookie.push( value[iCpt] )
          }
    
          cookie_header.push( cookie.join( "; " ) )
        end
      }

      return( cookie_header )
    end

Public Instance method: addFileDependencies( lFilenames )

Adds a group of file names to the collection of file names on which the current response is dependent. (Not Implemented)

# File lib/asp/response.rb, line 229
    def addFileDependencies( lFilenames )
      ## -> void
    end

Public Instance method: addFileDependency( xFilename )

Adds a single file name to the collection of file names on which the current response is dependent. (Not Implemented)

# File lib/asp/response.rb, line 235
    def addFileDependency( xFilename )
      ## -> void
    end

Public Instance method: addHeader( name, value )

Adds a new HTTP header and a value to the HTTP response

# File lib/asp/response.rb, line 38
    def addHeader( name, value )
      @hxHeader.store( name, value )
    end

Public Instance method: appendCookie( cookie )

(Not Implemented)

# File lib/asp/response.rb, line 240
    def appendCookie( cookie )
      ## -> void
    end

Public Instance method: appendHeader( name, value )

Alias for addHeader

Public Instance method: appendToLog( message )

Adds a string to the end of the server log entry

# File lib/asp/response.rb, line 44
    def appendToLog( message )
      @oApacheRequest.server.log_error( "[Ruby/ASP] [%d] %s", $$, message )
    end

Public Instance method: applyAppPathModifier( xVirtualPath )

Adds a session ID to the virtual path if the session is using cookieless session state and returns the combined path. If cookieless session state is not used, ApplyAppPathModifier returns the original virtual path. (Not Implemented)

# File lib/asp/response.rb, line 246
    def applyAppPathModifier( xVirtualPath )
      ## -> string
    end

Public Instance method: binaryWrite( data )

Writes data directly to the output without any character conversion

# File lib/asp/response.rb, line 27
    def binaryWrite( data )
      $stdout.binmode
      print data
    end

Public Instance method: buffer()

Specifies whether to buffer the page output or not (Not Implemented)

# File lib/asp/response.rb, line 125
    def buffer
      ## -> bool
    end

Public Instance method: bufferOutput()

Gets or sets a value indicating whether to buffer output and send it after the entire page is finished processing. (Not Implemented)

# File lib/asp/response.rb, line 131
    def bufferOutput
      ## -> bool
    end

Public Instance method: cache()

Gets the caching policy (expiration time, privacy, vary clauses) of a Web page.

# File lib/asp/response.rb, line 136
    def cache
      ## -> System.Web.HttpCachePolicy
      return @oApacheRequest.cache_resp
    end

Public Instance method: cacheControl()

Sets whether a proxy server can cache the output generated by ASP or not (Not Implemented)

# File lib/asp/response.rb, line 143
    def cacheControl
      ## -> string
    end

Public Instance method: clear( )

Clears any buffered HTML output (Not Implemented)

# File lib/asp/response.rb, line 252
    def clear( )
      ## -> void
    end

Public Instance method: clearContent( )

Alias for clear

Public Instance method: clearHeaders( )

Clears all headers from the buffer stream. (Not Implemented)

# File lib/asp/response.rb, line 260
    def clearHeaders( )
      ## -> void
    end

Public Instance method: close( )

Closes the socket connection to a client. (Not Implemented)

# File lib/asp/response.rb, line 266
    def close( )
      ## -> void
    end

Public Instance method: contentEncoding()

Gets the HTTP character set of the output stream.

# File lib/asp/response.rb, line 148
    def contentEncoding
      ## -> System.Text.Encoding
      return @oApacheRequest.content_encoding
    end

Public Instance method: contentEncoding=( str )

# File lib/asp/response.rb, line 153
    def contentEncoding=( str )
      @oApacheRequest.content_encoding=str
    end

Public Instance method: cookies( name, key, value=nil )

Sets a cookie value. If the cookie does not exist, it will be created, and take the value that is specified

  $Response.cookies('name', 'value');
  --> Set-Cookie: name=value; path=/

  $Response.cookies("Test", "data1", "test value");
  $Response.cookies("Test", "data2", "more test");
  $Response.cookies("Test", "Expires", &HTTP::Date::time2str(time+86400));
  $Response.cookies("Test", "Secure", 1);
  $Response.cookies("Test", "Path", "/");
  $Response.cookies("Test", "Domain", "host.com");
  --> Set-Cookie:Test=data1=test%20value&data2=more%20test;      #              expires=Fri, 23 Apr 1999 07:19:52 GMT;      #              path=/; domain=host.com; secure
# File lib/asp/response.rb, line 109
    def cookies( name, key, value=nil )
      if @hvCookies[name].nil? == true
        @hvCookies[name] = Hash::new
      end
      
      if value.nil? == false 
        @hvCookies[name][key] = String( value )
      else
        # we are assigning cookie with name the value of key
        @hvCookies[name]['Value'] = String( key )
      end 
    end

Public Instance method: end()

Stops processing a script, and returns the current result

# File lib/asp/response.rb, line 49
    def end
      @bEnd = 1
      goto :e
    end

Public Instance method: filter()

Gets or sets a wrapping filter object used to modify the HTTP entity body before transmission. (Not Implemented)

# File lib/asp/response.rb, line 159
    def filter
      ## -> stream
    end

Public Instance method: flush( )

Sends buffered HTML output immediately (Not Implemented)

# File lib/asp/response.rb, line 272
    def flush( )
      ## -> void
    end

Public Instance method: getHeader()

— Reserved for Ruby/ASP internal use —

# File lib/asp/response.rb, line 289
    def getHeader
      xTime = nil
      if @expires != nil
        xTime = Asp::Common::time2str( Time::now + @expires )
      elsif @expiresAbsolute != nil
        xTime = Asp::Common::str2time( @expiresAbsolute )
      end
      if xTime != nil
        @hxHeader.store( "Expires", xTime )
      end
      return @hxHeader
    end

Public Instance method: include( filename, *args )

This API extension calls the routine compiled from asp script in filename with the args *args.

# File lib/asp/response.rb, line 55
    def include( filename, *args )
      funcname = "i__"+rand( Time::new.to_i ).to_s+"__"+rand( Time::new.to_i ).to_s
      code = @oAspHandler.compile(filename)
      ##code = compile(filename)
      totalcode = "def " + funcname + "( args=nil )\n" + code + "\nend\n"
    
      @oAspHandler.load_code( totalcode, nil )
      if args.length == 0 
        xEvalData = "@oAspHandler." + funcname + "( nil )"
        eval( xEvalData.untaint ).untaint
      else
        xEvalData = "@oAspHandler." + funcname + "( args )"
        eval( xEvalData.untaint ).untaint
      end
    end

Public Instance method: isClientConnected()

Gets a value indicating whether the client is still connected to the server.

# File lib/asp/response.rb, line 164
    def isClientConnected
      ## -> bool
      return !@oApacheRequest.connection.aborted?
    end

Public Instance method: output()

Enables output of text to the outgoing HTTP response stream. (Not Implemented)

# File lib/asp/response.rb, line 171
    def output
      ## -> System.IO.TextWriter
    end

Public Instance method: outputStream()

Enables binary output to the outgoing HTTP content body. (Not Implemented)

# File lib/asp/response.rb, line 177
    def outputStream
      ## -> stream
    end

Public Instance method: pics( xValue )

Appends a value to the PICS label response header (Not Implemented)

# File lib/asp/response.rb, line 278
    def pics( xValue )
      ## -> void
    end

Public Instance method: redirect( url )

Redirects the user to a different URL

# File lib/asp/response.rb, line 90
    def redirect( url )
      self.addHeader( "location", url )
      @oApacheRequest.status = 302
    end

Public Instance method: redirectLocation( url )

Alias for redirect

Public Instance method: removeOutputCacheItem( xPath )

Static method removes from the cache all cached items associated with the specified path. (Not Implemented)

# File lib/asp/response.rb, line 284
    def removeOutputCacheItem( xPath )
      ## -> void
    end

Public Instance method: setCookie( name, key, value=nil )

Alias for cookies

Public Instance method: status( )

Specifies the value of the status line returned by the server

# File lib/asp/response.rb, line 182
    def status( )
      ## -> string
      return @oApacheRequest.status_line
    end

Public Instance method: statusCode( )

Gets the HTTP status code of the output returned to the client.

# File lib/asp/response.rb, line 188
    def statusCode( )
      ## -> int
      return @oApacheRequest.status
    end

Public Instance method: statusCode=( str )

Sets the HTTP status code of the output returned to the client.

# File lib/asp/response.rb, line 194
    def statusCode=( str )
      @oApacheRequest.status = str
    end

Public Instance method: statusDescription()

Gets the HTTP status string of the output returned to the client.

# File lib/asp/response.rb, line 199
    def statusDescription
      ## -> string
      return @oApacheRequest.status_line
    end

Public Instance method: statusDescription=( str )

Sets the HTTP status string of the output returned to the client.

# File lib/asp/response.rb, line 205
    def statusDescription=( str )
      @oApacheRequest.status_line = str
    end

Public Instance method: suppressContent()

Gets or sets a value indicating whether to send HTTP content to the client. (Not Implemented)

# File lib/asp/response.rb, line 211
    def suppressContent
      ## -> bool
    end

Public Instance method: trapInclude( filename, *args )

Calls $Response.include() with same arguments as passed to it, but instead traps the include output buffer and returns it.

# File lib/asp/response.rb, line 74
    def trapInclude( filename, *args )
      funcname = "i__"+rand( Time::new.to_i ).to_s+"__"+rand( Time::new.to_i ).to_s
      code = @oAspHandler.compile(filename)
      ##code = compile(filename)
      totalcode = "def " + funcname + "( args=nil )\n" + code + "\nend\n"

      if args.length == 0 
        o = Asp::Eval::new( totalcode, funcname, nil )
      else
        o = Asp::Eval::new( totalcode, funcname, args )
      end
      
      return o.get
    end

Public Instance method: write( data )

Writes a specified string to the output

# File lib/asp/response.rb, line 33
    def write( data )
      print data
    end

Public Instance method: writeFile( filename, *args )

Alias for include