Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

interface mimicking some of the Servlet implementation

View raclette.rb
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
# TO READ: http://en.wikipedia.org/wiki/Raclette
#
# A request comes in is parsed and made available as an object.
# The response attached to the request is made of 2 objects, a response object and a body (IO).
# The response is dispatched via the RequestDispatcher module which can have filters registered to process it.
# If the response starts being streamed, the response object is immediately frozen and only the body can be changed and flushed.
 
# When Rack meets Servlet
module Raclette
 
# Defines an object to provide client request information to a raclette.
# The raclette container creates a Raclette::Request object and passes it as an argument to the raclette's service method.
# A RacletteRequest object provides data including parameter name and values, attributes, and an input stream.
# Interfaces that extend Raclette::Request can provide additional protocol-specific data (for example, HTTP data is provided by Raclette::Http::Request.
class Request
 
# Returns a Hash of custom attributes set by the processing code.
# This hash is thread safe and available for writing.
# @return [Hash]
def attributes; end
 
# Returns the name of the character encoding used in the body of this request.
# @return [String]
def character_encoding; end
 
# Overrides the name of the character encoding used in the body of this request.
# @return [String]
def character_encoding=(val); end
 
# Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
# @return [Numeric]
def content_length; end
 
# Returns the MIME type of the body of the request, or null if the type is not known.
# @return [String, NilClass]
def content_type; end
 
# Retrieves the body of the request as binary data
# @return [IO]
def input_stream; end
 
# Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
# @return [String]
def locale; end
 
# Returns an Enumeration of locales indicating, in decreasing order starting with the preferred locale,
# the locales that are acceptable to the client based on the Accept-Language header.
# @return [Array<String>]
def locales; end
 
# Returns the parameters of this request.
# @return [Hash]
def params; end
 
# Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion,
# for example, HTTP/1.1.
# @return [String]
def protocol; end
 
# Retrieves the body of the request
# @return [IO]
def body; end
 
# Returns the Internet Protocol (IP) address of the client that sent the request.
# @return [String]
def remote_addr; end
 
# Returns the fully qualified name of the client that sent the request.
# @return [String]
def remote_host; end
 
# Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
# @return [RequestDispatcher]
def request_dispatcher; end
 
# Returns the name of the scheme used to make this request, for example, http, https, or ftp.
# @return [String]
def scheme; end
 
# Returns the host name of the server that received the request.
# @return [String]
def server_name; end
 
# Returns the port number on which this request was received.
# @return [Integer]
def server_port; end
 
# Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
# @return [Boolean]
def secure?; end
 
end
 
module HTTP
class Request < Raclette::Request
BASIC_AUTH = "BASIC"
FORM_AUTH = "FORM"
CLIENT_CERT_AUTH = "CLIENT_CERT"
DIGEST_AUTH = "DIGEST"
 
# Returns the name of the authentication scheme used to protect the raclette.
# @return [String]
def auth_type; end
 
# Returns the portion of the request URI that indicates the context of the request.
# @return [String]
def context_path; end
 
# Returns an array containing all of the Cookie objects the client sent with this request.
# @return [Cookie]
def cookies; end
 
# Returns the value of the specified request header as a long value that represents a Date object.
# @return [Numeric]
def date_header; end
 
# Returns the value of the specified request header as a String.
# @return [String]
def header; end
 
# Returns an enumeration of all the header names this request contains.
# @return [Array<String>]
def header_names; end
 
# Returns an enumeration of all the header names this request contains.
# @param [String] name the name of the header to return
# @return [Array<String>]
def headers(name); end
 
# Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
# @return [String]
def method; end
 
# Returns any extra path information associated with the URL the client sent when it made this request.
# @return [String]
def path_info; end
 
# Returns any extra path information after the raclette name but before the query string, and translates it to a real path.
# @return [String]
def path_translated; end
 
# Returns the query string that is contained in the request URL after the path.
# @return [String]
def query_string; end
 
# Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
# @return [String]
def remote_user; end
 
# Returns the session ID specified by the client.
# @return [String]
def request_session_id; end
 
# Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
# @return [String]
def request_uri; end
 
# Reconstructs the URL the client used to make the request.
# @return [String]
def request_url; end
 
# Returns the part of this request's URL that calls the raclette.
# @return [String]
def raclette_path; end
 
# Returns the current session associated with this request, or if the request does not have a session,
# and the create param is true, then it creates one.
# @param [Boolean] create
# @return [HttpSession]
def session(create=true); end
 
# Returns a Security::User object containing the name of the current authenticated user.
# @return [Security::User]
def current_user; end
 
# Checks whether the requested session ID came in as a cookie.
# @return [Boolean]
def request_session_id_from_cookie?; end
 
# Checks whether the requested session ID came in as part of the request URL.
# @return [Boolean]
def request_session_id_from_url?; end
 
# Checks whether the requested session ID is still valid.
# @return [Boolean]
def request_session_valid?; end
 
# Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
# @return [Boolean]
def current_user_in_role?(role); end
end
end
 
 
# Defines an object to assist in sending a response to the client.
class Response
 
# Indicates if the response is being streamed or not.
# @return [Boolean]
def streamed?; end
 
# Forces any content in the buffer to be written to the client.
# @return [Boolean]
def flush_buffer; end
 
# Returns the actual buffer size used for the response.
# @return [Integer]
def buffer_size; end
 
# Sets the preferred buffer size for the body of the response.
# @return [Integer]
def buffer_size=(val); end
 
# Returns the name of the charset used for the MIME body sent in this response.
# @return [String]
def character_encoding; end
 
# Returns the locale assigned to the response.
# @return [String]
def locale; end
 
# Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.
# @return [String]
def locale=(val); end
 
# Returns a boolean indicating if the response has been committed.
# @return [Boolean]
def committed?; end
 
# Clears any data that exists in the buffer as well as the status code and headers.
# @return [Boolean]
def reset; end
 
# Clears the content of the underlying buffer in the response without clearing headers or status code.
# @return [Boolean]
def reset_buffer; end
 
# REturns the length of the content body in the response.
# @return [Integer]
def content_length; end
 
# Sets the length of the content body in the response In HTTP, this method sets the HTTP Content-Length header.
# @return [Integer]
def content_length=(val); end
 
# Returns the content type of the response being sent to the client.
# @return [String]
def content_type; end
 
# Sets the content type of the response being sent to the client.
# @return [String]
def content_type=(val); end
 
end
 
class HTTP < Response
# Status code (202) indicating that a request was accepted for processing, but was not completed.
ACCEPTED = 202
# Status code (502) indicating that the HTTP server received an invalid response from a server it consulted when acting as a proxy or gateway.
BAD_GATEWAY = 502
# Status code (400) indicating the request sent by the client was syntactically incorrect.
BAD_REQUEST = 400
# Status code (409) indicating that the request could not be completed due to a conflict with the current state of the resource.
CONFLICT = 409
# Status code (100) indicating the client can continue.
CONTINUE = 100
# Status code (201) indicating the request succeeded and created a new resource on the server.
CREATED = 201
# Status code (417) indicating that the server could not meet the expectation given in the Expect request header.
EXPECTATION_FAILED = 417
# Status code (403) indicating the server understood the request but refused to fulfill it.
FORBIDDEN = 403
# Status code (504) indicating that the server did not receive a timely response from the upstream server while acting as a gateway or proxy.
GATEWAY_TIMEOUT = 504
# Status code (410) indicating that the resource is no longer available at the server and no forwarding address is known.
GONE = 410
# Status code (505) indicating that the server does not support or refuses to support the HTTP protocol version that was used in the request message.
HTTP_VERSION_NOT_SUPPORTED = 505
# Status code (500) indicating an error inside the HTTP server which prevented it from fulfilling the request.
INTERNAL_SERVER_ERROR = 500
# Status code (411) indicating that the request cannot be handled without a defined Content-Length.
LENGTH_REQUIRED = 411
# Status code (405) indicating that the method specified in the Request-Line is not allowed for the resource identified by the Request-URI.
METHOD_NOT_ALLOWED = 405
# Status code (301) indicating that the resource has permanently moved to a new location, and that future references should use a new URI with their requests.
MOVED_PERMANENTLY = 301
# Status code (302) indicating that the resource has temporarily moved to another location, but that future references should still use the original URI to access the resource.
MOVED_TEMPORARILY = 302
# Status code (300) indicating that the requested resource corresponds to any one of a set of representations, each with its own specific location.
MULTIPLE_CHOICES = 300
# Status code (204) indicating that the request succeeded but that there was no new information to return.
NO_CONTENT = 204
# Status code (203) indicating that the meta information presented by the client did not originate from the server.
NON_AUTHORITATIVE_INFORMATION = 203
# Status code (406) indicating that the resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.
NOT_ACCEPTABLE = 406
# Status code (404) indicating that the requested resource is not available.
NOT_FOUND = 404
# Status code (501) indicating the HTTP server does not support the functionality needed to fulfill the request.
NOT_IMPLEMENTED = 501
# Status code (304) indicating that a conditional GET operation found that the resource was available and not modified.
NOT_MODIFIED = 304
# Status code (200) indicating the request succeeded normally.
OK = 200
# Status code (206) indicating that the server has fulfilled the partial GET request for the resource.
PARTIAL_CONTENT = 206
# Status code (402) reserved for future use.
PAYMENT_REQUIRED = 402
# Status code (412) indicating that the precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.
PRECONDITION_FAILED = 412
# Status code (407) indicating that the client MUST first authenticate itself with the proxy.
PROXY_AUTHENTICATION_REQUIRED = 407
# Status code (413) indicating that the server is refusing to process the request because the request entity is larger than the server is willing or able to process.
REQUEST_ENTITY_TOO_LARGE = 413
# Status code (408) indicating that the client did not produce a requestwithin the time that the server was prepared to wait.
REQUEST_TIMEOUT = 408
# Status code (414) indicating that the server is refusing to service the request because the Request-URI is longer than the server is willing to interpret.
REQUEST_URI_TOO_LONG = 414
# Status code (416) indicating that the server cannot serve the requested byte range.
REQUESTED_RANGE_NOT_SATISFIABLE = 416
# Status code (205) indicating that the agent SHOULD reset the document view which caused the request to be sent.
RESET_CONTENT = 205
# Status code (303) indicating that the response to the request can be found under a different URI.
SEE_OTHER = 303
# Status code (503) indicating that the HTTP server is temporarily overloaded, and unable to handle the request.
SERVICE_UNAVAILABLE = 503
# Status code (101) indicating the server is switching protocols according to Upgrade header.
SWITCHING_PROTOCOLS = 101
# Status code (307) indicating that the requested resource resides temporarily under a different URI.
TEMPORARY_REDIRECT = 307
# Status code (401) indicating that the request requires HTTP authentication.
UNAUTHORIZED = 401
# Status code (415) indicating that the server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
UNSUPPORTED_MEDIA_TYPE = 415
# Status code (305) indicating that the requested resource MUST be accessed through the proxy given by the Location field.
USE_PROXY = 305
end
 
module RequestDispatcher
module_function
def filter(request, response); end
def register_filter(filter); end
end
 
module Security
# basic interface representing a system user
class User; end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.