eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HTTPHeaderParser':

Home

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

Class: HTTPHeaderParser


Inheritance:

   Object
   |
   +--HTTPHeaderParser

Package:
stx:goodies/webServer
Category:
Net-Communication-HTTP-Server
Version:
rev: 1.12 date: 2023/11/29 14:51:17
user: cg
file: HTTPHeaderParser.st directory: goodies/webServer
module: stx stc-classLibrary: webServer

Description:


an incremental header parser.
reads just enough from a header to retrieve a given header-key-value.

eg.
    |request parser|

    request := 
c'NOTIFY * HTTP/1.1\r
Host: 239.255.255.250:1900\r
NT: ssdp:testService\r
NTS: ssdp:alive\r
USN: uuid:2ABD6992-5F53-E257-21DE-37F10950FD0A::exepts-MBP::ssdp:testService\r
Location: http://test.local/\r
Cache-Control: max-age=180\r
\r
\r
'.
    parser := HTTPHeaderParser headerString:request.
    Transcript showCR:(parser fieldValueFor:'NT').
    Transcript showCR:(parser fieldValueFor:'USN').
    Transcript showCR:(parser fieldValueFor:'nts').
    Transcript showCR:(parser fieldValueFor:'cache-control').

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:

instance creation
o  headerString: aHeaderString
instantiate a new header parser on aHeaderString


Instance protocol:

accessing
o  headerString

o  headerString: aString

backward compatibility
o  fieldValueFor: aFieldKey
return the value for a header field key or nil if absent.
Use a lowercase key for slightly faster access (but uppercase is now allowed)

o  fieldValueFor: aFieldKey ifAbsent: fallBackValue
return the value for a header field key or the value from fallBackValue if absent.
Use a lowercase key for slightly faster access (but uppercase is now allowed)

header line accessing
o  at: aFieldKey
return the value for a header field key or nil if absent.
Use a lowercase key for slightly faster access (but uppercase is now allowed)

o  at: aFieldKey ifAbsent: fallBackValue
return the value for a header field key or the value from fallBackValue if absent.
Use a lowercase key for slightly faster access (but uppercase is now allowed)

o  fieldValues
return all field values as a dictionary, indexed by key

o  startLine
return the first line (which contains the request type)

private actions
o  parseHeader
parse all header lines and remember as key-value pairs in headerLines

o  parseHeaderForFieldKey: aFieldKey
continue parsing lines until aFieldKey is encountered.
Then return that value.
On the fly, remember what has been read so far

queries
o  atEnd
CRLF CRLF

o  nextLine
Modified (format): / 21-05-2021 / 12:48:08 / cg



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 15:50:17 GMT