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.109 date: 2019/07/13 12:22:17
user: cg
file: HTTPResponse.st directory: goodies/webServer
module: stx stc-classLibrary: webServer
Author:
Christian Penk

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)


Related information:

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

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

o  contentType: aContentType contentLength: aNumber expirationTime: aTimeStamp

o  expirationTime: aTimeStamp
the responses expirationTimestamp; consider to 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

html reply composition
o  nextPutAll: aString

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

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
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  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.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 16 Apr 2021 11:52:27 GMT