eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HTTPResponse':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: HTTPResponse


Inheritance:

   Object
   |
   +--HTTPResponse
      |
      +--FCGIResponse

Package:
stx:goodies/webServer
Category:
Net-Communication-HTTP-Server
Version:
rev: 1.118 date: 2023/11/23 10:34:51
user: cg
file: HTTPResponse.st directory: goodies/webServer
module: stx stc-classLibrary: webServer

Description:


represents a response to an HTTP request as constructed (filled in)
by HTTP-Services.


[instance variables:]
    header              collects all header data
    data                a chunk of data to send (if data is available as String or ByteArray)
    dataStream          a stream collecting (writeStream) or providing (readStream) the replyData
                        (if data is nil)
    request             the request for which this is a reply
    cookies             cokies to set in the client
    binary              ?
    responseAlreadySent flag set by services which send something on their own behalf
                        (prevent the response from being sent by the server at the end)

copyright

COPYRIGHT (c) 2003 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

constants
o  REPLYCODE_BADREQUEST

o  REPLYCODE_FORBIDDEN

o  REPLYCODE_GONE

o  REPLYCODE_NOTFOUND

o  reasonPhrasesDictionary
returns a dictionary which maps HTTP-codes to a descriptive message text

instance creation
o  request: aRequest
returns an initialized instance for the request


Instance protocol:

accessing
o  binary
get the binary mode flag (data is bytes as opposed to text)

o  binary: aBoolean
set/clear binary mode (data is bytes as opposed to text)

o  binaryData: aStreamOrBytes contentType: contentType
setup to return the contents of a binary stream
(typically: image data)

o  binaryDataStream: aStreamOrBytes contentType: contentType
setup to return the contents of a binary stream
(typically: image data)

o  cookies
a collection of cookies (to be filled by the service)

o  data

o  data: bytesOrCharacters
set the response data en-bloque.
Useful if the data is already available in a service (for example, from a cache)

o  data: bytesOrCharacters contentType: aMimeType
set the response data en-bloque and the type.
Useful if the data is already available in a service (for example, from a cache)

o  dataFile: aFilename
set the response data to be read from a file.
Useful if the data is big and should not be read in for transmission

o  dataFile: aFilename contentType: aMimeType
set the response data to be read from a file and the content type.
Useful if the data is big and should not be read in for transmission

o  dataStream

o  dataStream: aStream
set the response dataStream.
Useful if the data is to be read from a file and should not be read in for transmission

o  dataStream: aStream contentType: aMimeType
set the response dataStream and the content type.
Useful if the data is to be read from a file and should not be read in for transmission

o  expectedAuthRealm

o  expectedAuthRealm: aRealm

o  header

o  header: something

o  replyPresenter

o  replyPresenter: aDecoratingPresenterOrNil

o  replyPresenterDataStream

o  request

o  request: something

o  responseAlreadySent: something

actions
o  addCookie: aCookie

header access
o  addLineToHeader: aString

o  cacheControl

o  contentDisposition: aContentDispositionString filename: aFileNameString

o  contentLength

o  contentLength: aNumber

o  contentLocation

o  contentLocation: aUrl

o  contentType

o  contentType: aContentType
set the mimetype of the response

o  contentType: aContentType contentLength: aNumber expirationTime: aTimeStamp

o  expirationTime: aTimeStamp
the responses expirationTimestamp.
Obsolete, only for old HHTP/1.0 caches, which are long gone.
Use #maxAge:

o  lastModified: aNumber

o  location: aUrl

o  maxAge: aSecondsIntegerOrTimeDuration
how many seconds may this response be cached

o  replyHeader: aCompleteHeaderString
some services (e.g. comanche services) generates his own response header
send this header if set from service

o  responseCode

o  responseCode: aNumber

o  setNoCache
Tell the client and possible caches to not cache the response

html reply composition
o  nextPutAll: aString
append aString to the collected reply.
Answer the receiver

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 <)

o  nextPutLine: aString

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 <)

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

o  reply: aString with: aParameter
collect part of a reply (i.e. append aString to the reply buffer);
aString may contain %1 escape which is replaced by aParameter.

o  replyCR

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

initialization
o  initialize
(comment from inherited method)
just to ignore initialize to objects which do not need it

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

old html reply composition
o  bodyEnd
Write </BODY>

o  bodyStart
Write <BODY>

o  cr
OLD stuff - please use a TreeBuilder

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
OLD stuff - please use a TreeBuilder

o  formSubmitButtonForString: aString
OLD stuff - please use a TreeBuilder

o  formSubmitButtonForString: aString name: aName
OLD stuff - please use a TreeBuilder

o  formSubmitButtonStringForString: aString name: aName
OLD stuff - please use a TreeBuilder

o  htmlEnd
OLD stuff - please use a TreeBuilder

o  htmlStart
OLD stuff - please use a TreeBuilder

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
an IMG tag for a real image (or an image file name)

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

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

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

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

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

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

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

o  inputFieldStringFor: varName type: aType size: size label: label initialValue: value append: aString
strin for 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  pageFinish
finish the page.

o  refreshStringFor: aService selector: aSelector arguments: arguments time: seconds
OLD stuff - please use a TreeBuilder

o  refreshStringFor: aService selector: aSelector time: seconds
OLD stuff - please use a TreeBuilder

o  stxPoweredByString
OLD stuff - please use a TreeBuilder

o  stxPoweredByStringForService: serviceOrNil
OLD stuff - please use a TreeBuilder

o  table: aBlock
OLD stuff - please use a TreeBuilder

o  table: aBlock attributes: attrString
OLD stuff - please use a TreeBuilder

o  tableEnd
OLD stuff - please use a TreeBuilder

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

o  tableRow: aBlock
OLD stuff - please use a TreeBuilder

o  tableRow: aBlock attributes: attrString
OLD stuff - please use a TreeBuilder

o  tableRowEnd
OLD stuff - please use a TreeBuilder

o  tableRowStart: attrString
OLD stuff - please use a TreeBuilder

o  tableStart: attrString
OLD stuff - please use a TreeBuilder

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.

old html-reply-composition-stx-obsolete
o  favIconLinkForSTX
notice: this requires a file service to run for the /files url
on the ../../goodies/webServer/data/sampleServerDir/files/ folder

o  pageSTXFooter
Write the standard page footer.

o  stxBodyEnd
attention: some (old) services still use this!

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.

o  stxPageParameters
attention: some (old) services still use this!

o  stxReply: aString
attention: some (old) services still use this!

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

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

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

queries
o  isErrorResponse

o  startReadRequestTime

sending
o  send
copy over from some stream and send it as a response.
Any already collected replyData is ignored.
Typically used with big files, which we do not want to fill up our memory
(i.e. the document is not loaded as a whole)

Usage example(s):

try hard to send it as one block

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



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 23 Nov 2024 08:02:58 GMT