'From Pharo2.0 of 7 March 2013 [Latest update: #20624] on 19 October 2013 at 7:59:57 pm'! !HttpRequest methodsFor: 'private' stamp: 'HernanMoralesDurand 10/19/2013 19:54'! parseCookies: aString "PRIVATE: Parse a string in the format: Cookie: NAME1=OPAQUE_STRING1; NAME2=OPAQUE_STRING2 ..." | dict | dict := Dictionary new. (aString findTokens: ';') do: [ : pairStr | | pair | (pair := pairStr findTokens: '=') size > 0 ifTrue: [ | key value | key := pair first trimBoth asSymbol. value := pair size > 1 ifTrue: [ pair second trimBoth ] ifFalse: [ nil ]. dict at: key put: value] ifFalse: ["self log: 'Cookie invalid pair format: ''' , pairStr , ''''"] ]. ^ dict! ! !ModDoc class methodsFor: 'initialization' stamp: 'HernanMoralesDurand 10/19/2013 19:59'! initialize " self initialize " DelimiterTranslation := (0 to: 255) as: ByteArray. DelimiterTranslation at: ($/ asciiValue + 1) put: FileSystem disk separator asciiValue. "Register this class for startUp notification (in case we are started on a platform with a differen path name delimiter" Smalltalk addToStartUpList: self. ! ! !HttpRequest class methodsFor: 'parsing' stamp: 'HernanMoralesDurand 10/19/2013 19:55'! parseHttpHeader: string | dict key value start end more colonPos fieldDelims lastKey keyValueDelim crlf | dict := Dictionary new. crlf := String crlf. string isEmptyOrNil ifTrue: [ ^ dict ]. fieldDelims := crlf asCharacterSet. keyValueDelim := $:. more := true. start := end := 1. lastKey := ''. [ end := string indexOfAnyOf: fieldDelims startingAt: start. end == 0 ifTrue: [end := string size. more := false] ifFalse: [end := end - 1]. (end >= start and: [start < string size]) ifTrue: [ (string at: start) isSeparator ifTrue: [ dict at: lastKey put: (dict at: lastKey), (string copyFrom: start to: end)] ifFalse: [ colonPos := string indexOf: keyValueDelim startingAt: start. (colonPos > end or: [colonPos == 0]) ifTrue: [ key := (string copyFrom: start to: end) translateToLowercase. value := ''] ifFalse: [ key := (string copyFrom: start to: colonPos-1) translateToLowercase. value := (string copyFrom: colonPos+1 to: end) trimBoth ] ]. key isEmpty ifFalse: [ dict at: key put: value. lastKey := key. key := '' ]. start := string skipDelimiters: crlf startingAt: end+1 ]. more] whileTrue. ^ dict! ! ModDoc initialize!