eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HTTPRequest':

Home

everywhere
www.exept.de
for:
[back]

Class: HTTPRequest


Inheritance:

   Object
   |
   +--HTTPRequest
      |
      +--FCGIRequest

Package:
stx:goodies/webServer
Category:
Net-Communication-HTTP-Server
Version:
rev: 1.212 date: 2010/04/26 11:41:05
user: sr
file: HTTPRequest.st directory: goodies/webServer
module: stx stc-classLibrary: webServer
Author:
Christian Penk

Description:


represents an HTTP request as received by the HTTPServer.


[instance variables:]
    server              the server from which this request was received
    connection          the socket conection from which this request was received
    peer                the sender of this request
    peerName

    rawRequestString:   the whole request incl. any POST-data (required for com-swiki)
    rawHeader           the raw http-header (without data)
    headerDictionary    extracted fields
    headerLines         header lines
    method              ?
    httpVersion         httpVersion from the header
    url                 the requests original url
    postDataFields      POST request arguments
    urlParameters       &-parameters as extracted from the URL
    contentLength       contentLength from the header
    contentType         contentType from the header
    contentEncoding     contentEncoding from the header
    connectionAttributes     connectionAttributes from the header (Keep/close etc.)
    userAgent           userAgent from the header (IE, mozilla etc.)
    authorization       authorization from the header
    acceptedTypes       acceptedTypes from the header
    acceptedEncodings   acceptedEncodings from the header
    acceptedCharsets    acceptedCharsets from the header
    acceptedLanguages   acceptedLanguages from the header
    referer             referer from the header
    host                host from the header
    soapAction          soapAction from the header
    cookies             cookies from the header

    data                the POST-data alone
    postData            ?
    userId              ?
    serviceLinkName     ?
    service             ?
    relativePath        URL relative to service-linkName
    message             the original message; split and preparsed
    arguments           additional arguments for object-requests (preparsed from the url)
    selector            ?
    multipartBoundary   ?
    multiPartChunks     ?
    queryString         url parameters - rest after any in { & ; ? }
    response            response object


Related information:

    http://www.w3.org/Protocols/rfc2616/rfc2616.html
    HTTPResponse
    HTTPServer
    HTTPInterface

Class protocol:

defaults
o  allowedRequestMethods

helpers
o  extractAcceptedFromLine: acceptLine

o  extractMultipartBoundaryFromContentType: contentTypeLine

instance creation
o  server: httpServer connection: connection

serving-helpers
o  controlCharacters

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  escape: arg

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  escapeCharacterEntities: arg

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  unEscape: arg

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  urlEncoded: arg

** This is an obsolete interface - do not use it (it may vanish in future versions) **


Instance protocol:

accessing
o  arguments
the arguments of a SelectorService

o  authenticator

o  authenticator: something

o  connection

o  multiPartChunks

o  pathRelativeToService
set the path relative to the services root path.
- without a leading /

o  pathRelativeToService: aString
set the path relative to the services root path.
- without a leading /

o  queryString

o  rawUrl

o  rawUrl: something

o  relativePath
Obsolete: use #pathRelativeToService.
get the path relative to the services root path.
- with a leading /

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  replyPresenter

o  response

o  selector
the selector of a SelectorService

o  service

o  service: serviceArg serviceLinkName: serviceLinkNameArg

o  serviceRequestContext

o  serviceRequestContext: something

accessing-http request data
o  cookiesAt: aString
Selects all the cookies with the name aString.
<return: Collection>

o  data

o  getURLQueryString

o  hasUrlParameter: key
true, if key is present in the url-param (after the urls path, separated by &'s)

o  multiPartChunkDataAt: key

o  multiPartChunkDataAt: key ifAbsent: replacement

o  multiPartChunkFilenameAt: key

o  multiPartChunkFilenameAt: key ifAbsent: aBlock

o  peer

o  peer: something
set the value of the instance variable 'peer' (automatically generated)

o  peerName

o  peerName: something
set the value of the instance variable 'peerName' (automatically generated)

o  postData

o  postDataFieldAt: key
a field (typically of a POST request)

o  postDataFieldAt: key ifAbsent: replacement
a field (typically of a POST request)

o  postDataFields
the fields (typically of a POST request).
Nil if there are none.

o  postDataVectorAt: key
all url parameters for key (after the urls path, separated by &'s)

o  postDataVectorAt: key ifAbsent: replacement
all url parameters for key (after the urls path, separated by &'s)

o  rawRequestString

o  selector: selectorArg arguments: argumentsArg
remember selector and arguments of a SelectorService (for the service)

o  server

o  serverHostName

o  serviceLinkName

o  serviceLinkName: something

o  socketAddress
answer the address that received the request.
This is one of the addresses assigned to the server

o  urlParameterAt: key
a scalar url-param (after the urls path, separated by &'s).
For example, if the url is 'foo?bar=1?baz=2', then
urlParameterAt:'bar'
would return '1' (a string)

o  urlParameterAt: key ifAbsent: replacement
a scalar url-param (after the urls path, separated by &'s)

o  urlParameterAt: key put: aString

o  urlParameterVectorAt: key
all url parameters for key (after the urls path, separated by &'s)

o  urlParameterVectorAt: key ifAbsent: replacement
all url parameters for key (after the urls path, separated by &'s)

o  urlParameters
the url-params (after the urls path, separated by &'s).
Nil if there are none.

o  valueOfNumericPostDataField: fieldName

accessing-http request header
o  acceptedCharsets
as extracted from the http-header,
returns key-value associations

o  acceptedEncodings
as extracted from the http-header

o  acceptedLanguages
return the value of the instance variable 'acceptedLanguages' (automatically generated)

o  acceptedTypes
as extracted from the http-header, if no Accept: field is present,
then it is assumed that text/plain and text/html are accepted.

o  authorizationHeader
as extracted from the http-header

o  connectionAttributes

o  contentEncoding

o  contentLength
return the value of the instance variable 'contentLength' (automatically generated)

o  contentType

o  cookies

o  fieldValueFor: aFieldKey

o  fieldValues
answer all the header fields as a Dictionary

o  header
the header as a dictionary

o  host

o  httpVersion

o  method

o  method: aString

o  multipartBoundary

o  rawHeader

o  referer
yes, I know that 'referer' is a misspelling of 'referrer'.
However, somehow it made it into the HTTP standard, and is called 'referer' there - sigh.

o  referrer
the referring page - if known.
Notice the mispelling below - due to the fact that the misspelling made it into
the HTTP standard

o  soapAction

o  url

o  userAgent

accessing-http response data
o  binary: aBoolean

o  expirationTime: aTimeStamp
the responses expirationTimestamp; consider to use response maxAge:

o  replyData: aStringOrBytes

o  replyHeader
return the value of the instance variable 'replyHeader' (automatically generated)

o  resetResponseData
start anew collecting response data
(i.e. throw away what has been already collected)

o  responseContentType: something
set the value of the instance variable 'contentType' (automatically generated)

accessing-sessions
o  getSession

o  getSession: shouldCreateIfNone
Get the current valid session associated with the request.
If shouldCreateIfNone is true then either a new session will be created
or the current one will be returned if one exists.
Answer nil, if shouldCreateIfNone is false and there is no session.

The session's scope is a single service (over all of its possible linkNames).

<return: HTTPSession | nil>

authentication
o  authenticateForRealm: aRealm
authenticate myself for a realm.
Raise an error, if authentication fails

o  authenticatedUsername
get the user, that has been authenticated
or nil, if there is none

o  isForbiddenUserAgent: aUserAgentString
there are certain user agents which we definitely do not want in our house:

error reporting
o  reportBadRequest: msg
bad request.

o  reportException: ex
Write an error report.

o  reportForbidden: msg
access forbidden

o  reportHTTPVersionNotSupported: msg

o  reportMethodNotAllowed: msg method: badMethod url: badURL
method (such as POST, PUT etc.) is not allowed.

o  reportMovedPermanently: newUrl
page has been permanently moved to another location, newUrl.

o  reportNotAcceptable: typeAvailable
not acceptable - content-type not in accept list.

o  reportNotFound: msg
document/object was not found.
Take care: IE6 will not show this message, but its own message,
if the whole repsonse is shorter than 512 bytes and
'Show Short HTTP Error Messages' is on in Internet Settings

o  reportRequestTimeout: message
request timeout - the request was transmitted too slowly.

o  reportServerError: msg moreInfo: aStringOrNil
server error.

o  reportServiceUnavailable: msg
report temporary down - will not return (i.e. aborts).

o  reportUnauthorized: messageText
no authorization - ask for authorization.

o  reportUnsupportedFeature: msg
bad request.

o  sendErrorResponseForResponseCode: aStatusCode

o  sendErrorResponseForResponseCode: aStatusCode body: bodyText

o  sendErrorResponseForResponseCode: aStatusCode message: messageString
Send an error for aStatusCode (e.g. 440 - Not found).
messageString may contain additional information

o  sendErrorResponseForResponseCode: aStatusCode title: titleText body: bodyText

o  sendErrorResponseForStatusCode: aStatusCode

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  sendErrorResponseForStatusCode: aStatusCode body: bodyText

** This is an obsolete interface - do not use it (it may vanish in future versions) **

header parsing
o  extractCookiesFrom: line

o  headerParser

o  parseFirstLine

o  parseHeader

o  rawRequestString: rawRequestStringArg rawHeader: rawHeaderArg data: dataArg

html reply composition
o  bodyEnd
Write </BODY>

o  bodyStart
Write <BODY>

o  formEnd
append the standard footer for a form.

o  formFooter
Write the standard footer for a form.

o  formResetButton
generate a reset button for a form.

o  formSubmitButton

o  formSubmitButtonForString: aString

o  formSubmitButtonForString: aString name: aName

o  formSubmitButtonStringForString: aString name: aName

o  htmlEnd

o  htmlStart

o  imageFor: anImageOrImageFilename
generate an IMG tag for a real image (or an image file name)

o  imageFor: anImageOrImageFilename alt: alt
an IMG tag for a real image (or an image file name)

o  imageLinkTextFor: anImageOrImageFilename alt: alt
return an IMG tag for a real image (or an image file name)

o  inputFieldFor: varName label: label initialValue: value
an input field - must be within a form

o  inputFieldFor: varName size: size label: label initialValue: value
an input field - must be within a form

o  inputFieldFor: varName type: aType size: size label: label initialValue: value
an input field - must be within a form

o  inputFieldFor: varName type: aType size: size label: label initialValue: value append: aString
an input field - must be within a form.
type: 'password' | 'checkbox' | 'submit' | 'reset' | nil

o  inputFieldStringFor: varName type: aType size: size label: label initialValue: value append: aString
an input field - must be within a form.
type: 'password' | 'checkbox' | 'submit' | 'reset' | nil

o  label: labelString id: idString value: anObject
Add a table row for the given data to the reply.

o  label: labelString text: aString id: idString rows: rows cols: cols
Build a textarea form field.

o  refreshStringFor: aService selector: aSelector arguments: arguments time: seconds

o  refreshStringFor: aService selector: aSelector time: seconds

o  table: aBlock

o  table: aBlock attributes: attrString

o  tableEnd

o  tableFormFooter
Close the table and write the standard footer for a form.

o  tableRow: aBlock

o  tableRow: aBlock attributes: attrString

o  tableRowEnd

o  tableRowStart: attrString

o  tableStart: attrString

o  titleAndHeader: aString
Write a standard header and set the document title.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  unformattedCodeTextEnd
end some plainText.

o  unformattedCodeTextStart
start some plainText.

o  unformattedText: aString
add some plainText.

o  unformattedTextEnd
end some plainText.

o  unformattedTextStart
start some plainText.

html reply composition stx
o  pageFinish
finish the page.

o  pageSTXFooter
Write the standard page footer.

o  stxBodyEnd

o  stxBodyStart: aString
Write a standard stx body with a headline #f6feff

o  stxBodyStart: aString homeLink: aHomeLink
Write a standard stx body with a headline #f6feff

o  stxBodyStart: aString homeLink: aHomeLink afterButtons: afterButtonsString
Write a standard stx body with a headline #f6feff

o  stxPageFinish
finish the page.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  stxPageParameters

o  stxPoweredByString

o  stxReply: aString

o  title: aString
Write a standard header and set the document title.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  title: aString with: someMoreHeaderStuff
Write a standard header and set the document title. Also used for logging purposes.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

html reply composition-stream protocol
o  nextPutAll: aString
append aString to the collected reply.

o  nextPutAllEscaped: aString
append aString to the collected reply.
The string is processed, by replacing html-special characters by there html-equivalent (such as '>' into &lt;)

o  nextPutLine: aString
append aString to the collected reply and append a lineBreak.

o  nextPutLineEscaped: aString
append aString to the collected reply and append a cr.
The string is processed, by replacing html-special characters by there html-equivalent (such as '>' into &lt;)

links-html generation
o  homeWebLinkForText: nameString
Return HTML code for a link to anObject using the given name and message selector.

o  linkIdFor: aService
Return the linkId to send aMessage to anObject.
if the request is for another service, answer the first link for the service

o  linkIdFor: aService argument: argumentString
Return the linkId to send aMessage to anObject.
Create a new linkId if necessary.

o  linkIdFor: aService selector: aSelector
Return the linkId to send aMessage to anObject.
Create a new linkId if necessary.

o  linkIdFor: aService selector: aSelector argument: argumentString
Return the linkId to send aMessage to anObject.
Create a new linkId if necessary.

o  webLinkForImage: imageOrImageFilename service: aService argument: aSelector
Return HTML code for a link to anObject using the given name and message selector.

o  webLinkForImage: imageOrImageFilename service: aService selector: aSelector
Return HTML code for a link to anObject using the given name and message selector.

o  webLinkForText: nameString link: aLinkId
Return HTML code for a linkId using the given name
and message selector. When the link is followed,
aSelector plus argument will be sent to anObject.

o  webLinkForText: nameString service: aService argument: anArgument
Return HTML code for a link to aService using the given nameString
and aSelector. When the link is followed,
aSelector plus argument will be sent to aService.

o  webLinkForText: nameString service: aService selector: aSelector
Return HTML code for a link to anObject using the given name and message selector.

o  webLinkForText: nameString service: aService selector: aSelector argument: anArgument
Return HTML code for a link to aService using the given nameString
and aSelector. When the link is followed,
aSelector plus argument will be sent to aService.

o  webLinkText: nameString target: targetString service: aService selector: aSelector
Return HTML code for a link to aService using the given name and message selector.

logging
o  logAccess

o  logError: aString

misc
o  environmentValueFor: aFieldKey
return the value of an environment value.
We have none, so return nil here. This is defined for FastCGI compatibility

obsolete
o  escape: aString
use class escape:

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  unEscape: aString
use class unEscape:

** This is an obsolete interface - do not use it (it may vanish in future versions) **

printing
o  printOn: aStream

queries
o  fullPath

o  isGET
return true, if the request was a HEAD request

o  isHEAD
return true, if the request was a HEAD request

o  isPOST
return true, if the request was a POST request

o  isSecure
answer true, if this request was issued over an secure channel (SSL/TLS)

o  startReadRequestTime

o  timeToPerform
in milliseconds

response collecting
o  addCookie: cookie
send a cokkie with the response.
Remember the cookie in the request, so that session cookies
will not be created twice

o  addToReplyHeader: aString
collect part of a header (i.e. append aString to the reply header).

o  reply: aString
collect part of a reply (i.e. append aString to the reply buffer).

o  replyCR
Append a cr to the reply buffer

o  replyEscaped: aStringOrCharacter
collect part of a reply (i.e. append aString to the reply buffer).
Special character (lt, gt) are escaped.

o  replyHeader: aString

o  replyURLEscaped: aStringOrCharacter
collect part of a reply (i.e. append aString to the reply buffer).
URL-Special characters (&, space etc.) are escaped.

response sending
o  redirectTo: link
redirect both per META and per 302-location-redirect.
(because content-location redirection doesn't work for most of the browsers)

o  sendBinary: aStreamOrBytes type: contentType
send some binary data as a response.
Typically used with images and non-text documents

o  sendBinaryData: binaryData type: contentType
send some binary data as a response.
Typically used with images and non-text documents

o  sendBinaryStream: aStreamOrBytes type: contentType
send some binary data as a response.
Typically used with images and non-text documents

o  sendImage: inImage
reply with a bitmap image.
For now, must send it as gif ... (could do jpg as well),
or even better, remember what types are supported by the browser

o  sendResponse
send the response

o  sendResponseWithType: aContentType
send the response

serving-helpers
o  checkAcceptableType: type

o  decodeFields: aString
Convert the form fields in Collection of strings into a dictionary.
collection is needed because e.g. (on <SELECT name=FOO MULTIPLE> by client selects more than one
FOO comes with same key and different values)
Each field should be of the form: &nameKey=collection of values

o  extractPostDataFields

o  extractURLParametersFromPath: path
answer the local part of the path without parameters.
As a side effect the parameters are stored in the instVar urlParameters

serving-processing
o  handleSOAPAction

o  reprocess

o  reprocessWithInternalURL: aNewInternalURL

o  reprocessWithServiceURL: aNewInternalServiceURL

o  robotPolicy
Return a text specifying our robots policy.
This is the answer to be given to webCrawlers and tells them,
which URLs (subtrees) should not be visited.
See
http://info.webcrawler.com/mak/projects/robots/norobots.html
for details.
The default here is to disallow everything.

o  url: aNewURL

serving-requests
o  generateReply
handle a request; generate the reply.

o  generateReplyForGetRequest
Generate the reply to a GET request.

o  generateReplyForHeadRequest
Generate the reply to a HEAD request (same as GET, but no data is sent at the end).

o  generateReplyForPostRequest
handle a post-request; generate the reply.

serving-serverState
o  checkMaintenanceMode
if server is in mainenance mode, no files are served to normal users.
Access to a server in maintenance mode is only possibly to a user
that has authenticated for maintenance service

setup from connection
o  initializeForServer: serverArg connection: connectionArg

o  postData: something


Private classes:

    MultipartChunk
    ReprocessRequest


ST/X 6.1.1; WebServer 1.620 at exept:8081; Mon, 21 May 2012 17:48:05 GMT