User:Saijanai Kuhn/http-in with squeak
'From Squeak4.1 of 17 April 2010 [latest update: #9957] on 6 August 2010 at 6:26:12 am'! WAComponent subclass: #SecondTestComponent instanceVariableNames: 'primURL postBody primResponse' classVariableNames: poolDictionaries: category: 'Seaside-Basic-Tests'!
!SecondTestComponent methodsFor: 'rendering' stamp: 'LDE 8/6/2010 03:13'! renderContentOn: html self renderExplanationOn: html. html form: [
html text: 'enter prim URL here: '. html textInput value: self primURL; callback: [ :value | self primURL: value ].
html break.
html text: 'POST body:'. html textInput value: self postBody; callback: [ :value | self postBody: value ]. html break.
html text: 'primResponse:'. html textInput value: self postBody.
html submitButton callback: [self postMessageToPrim] ]! !
!SecondTestComponent methodsFor: 'rendering' stamp: 'LDE 8/5/2010 23:08'! renderExplanationOn: html html paragraph: 'This form sends a HTTP POST to the primURL.'! !
!SecondTestComponent methodsFor: 'accessing' stamp: 'LDE 8/5/2010 23:17'!
postBody
"Answer the value of postBody"
^ postBody! !
!SecondTestComponent methodsFor: 'accessing' stamp: 'LDE 8/5/2010 23:17'! postBody: anObject "Set the value of postBody"
postBody := anObject! !
!SecondTestComponent methodsFor: 'accessing' stamp: 'LDE 8/5/2010 23:11'! primURL "Answer the value of primURL"
^ primURL! !
!SecondTestComponent methodsFor: 'accessing' stamp: 'LDE 8/5/2010 23:11'! primURL: anObject "Set the value of primURL"
primURL := anObject! !
!SecondTestComponent methodsFor: 'initialization' stamp: 'LDE 8/6/2010 03:01'!
initialize
super initialize.
primURL := 'enter prim URL here'.
postBody := 'your message goes here.'.
primResponse := 'no response yet'.! !
!SecondTestComponent methodsFor: 'as yet unclassified' stamp: 'LDE 8/6/2010 04:01'!
postMessageToPrim
| response |
response := (HTTPSocket httpPostDocument: primURL args: postBody asString accept: '*/*' request: ) content.
! !