vieweditattachhistoryswikistopchangessearchhelp

Western (Latin1) 決め打ち修正

SwikiModule >> #responseFrom:
responseFrom: dict
  | response content |
  response _ HttpResponse new.
  "header status"
  response status: (dict at: 'headerStatus' ifAbsent: [#ok]).
  "cacheing"
  (dict at: 'cacheing' ifAbsent: [false]) ifFalse: [
    response fieldAt: 'Pragma' put: 'no-cache';
      fieldAt: 'Expires' put: '0';
      fieldAt: 'Cache-Control' put: 'no-cache'].
  "location (in case of redirect)"
  (dict includesKey: 'location') ifTrue: [
    response fieldAt: 'Location' put: (dict at: 'location')].
  "authenticate (in case of unauthorized)"
  (dict includesKey: 'authenticate') ifTrue: [
    response fieldAt: 'WWW-Authenticate' put: (dict at: 'authenticate')].
  "content type"
  response contentType: (dict at: 'contentType' ifAbsent: ['text/html; charset=shift_jis']).
  "contents"
  content _ dict at: 'content'.
  (content isKindOf: String)
    ifTrue: [response contents: (ReadStream on: content)]
    ifFalse: [(content isKindOf: BlockContext)
      ifTrue: [response _ response asHttpPartialResponseBlock: content]
      ifFalse: [response contents: content]].
  "return the response to be served"
  ^response

このページを編集 (1159 bytes)


Congratulations! 以下の 1 ページから参照されています。

This page has been visited 2351 times.