[Vm-dev] when the vm crashes...
Bob Arning
arning315 at comcast.net
Fri Mar 28 18:04:34 UTC 2014
Skipped content of type multipart/alternative-------------- next part --------------
'From Squeak4.2 of 4 February 2011 [latest update: #10966] on 28 March 2014 at 1:50:24 pm'!
!SqueakSSL class methodsFor: 'examples' stamp: 'raa 3/28/2014 13:50'!
crashTesting2
"
SqueakSSL crashTesting2
"
| resp sss firstCopy prev results datum short t |
Transcript cr; show: 'ssl crash testing2'; cr.
firstCopy _ Dictionary new.
results _ OrderedCollection new.
[
1 to: 100 do: [ :i |
sss _ #('squeak' 'SqueakSSL') atRandom.
t _ [resp _ SqueakSSL google: sss] timeToRun.
short _ resp truncateTo: 50.
short _ short reject: [ :ch | ch asciiValue < 32].
prev _ firstCopy at: sss ifAbsentPut: [resp].
datum _ {i. sss. t. resp size. resp = prev. resp size = prev size. short}.
results add: datum.
WorldState addDeferredUIMessage: [
Transcript show: datum asString; cr.
].
(Delay forSeconds: 10 atRandom) wait.
].
WorldState addDeferredUIMessage: [
Transcript show: '----done-------'; cr.
].
] forkAt: 32.! !
!SqueakSSL class methodsFor: 'examples' stamp: 'raa 3/28/2014 13:50'!
crashTesting3
"
SqueakSSL crashTesting3
"
| resp sss firstCopy prev results datum short t |
Transcript cr; show: 'ssl crash testing'; cr.
firstCopy _ Dictionary new.
results _ OrderedCollection new.
[
1 to: 100 do: [ :i |
sss _ #('Main_Page' 'Wormholes') atRandom.
t _ [resp _ SqueakSSL notgoogle: '/en/wiki/',sss] timeToRun.
short _ resp truncateTo: 50.
short _ short reject: [ :ch | ch asciiValue < 32].
prev _ firstCopy at: sss ifAbsentPut: [resp].
datum _ {i. sss. t. resp size. resp = prev. resp size = prev size. short}.
results add: datum.
WorldState addDeferredUIMessage: [
Transcript show: datum asString; cr.
].
(Delay forSeconds: 10 atRandom) wait.
].
WorldState addDeferredUIMessage: [
Transcript show: '----done-------'; cr.
].
] forkAt: 32.! !
!SqueakSSL class methodsFor: 'examples' stamp: 'raa 3/28/2014 13:50'!
google: query
"An example HTTPS query to encrypted.google.com.
Example:
SqueakSSL google: 'squeak'.
SqueakSSL google: 'SqueakSSL'.
"
| hostName address socket ssl |
"Change the host name to try an https request to some other host"
hostName := 'encrypted.google.com'..
address := NetNameResolver addressForName: hostName.
socket := Socket newTCP.
"Connect the TCP socket"
socket connectTo: address port: 443.
socket waitForConnectionFor: 10.
"Set up SqueakSSL using the convenience APIs"
ssl := SqueakSSL on: socket.
["Let SqueakSSL handle the client handshake"
ssl connect.
"Verify that the cert is valid"
ssl certState = -1 ifFalse:[ "mac always -1??"
self error: 'The certificate is invalid (code: ', ssl certState,')'.
].
"If the certificate is valid, make sure we're were we wanted to go"
(ssl peerName match: hostName) ifFalse:[
self error: 'Host name mismatch: ', ssl peerName.
].
"Send encrypted data"
ssl sendData:
'GET /search?q=', query,' HTTP/1.0', String crlf,
'Host: ', hostName, String crlf,
'Connection: close', String crlf,
String crlf.
"Wait for the response"
^String streamContents:[:s|
[socket isConnected | socket dataAvailable]
whileTrue:[s nextPutAll: ssl receiveData]].
] ensure:[ssl destroy].
! !
!SqueakSSL class methodsFor: 'examples' stamp: 'raa 3/28/2014 13:50'!
notgoogle: query
| hostName address socket ssl |
"Change the host name to try an https request to some other host"
hostName := 'wiki.eveonline.com'..
address := NetNameResolver addressForName: hostName.
socket := Socket newTCP.
"Connect the TCP socket"
socket connectTo: address port: 443.
socket waitForConnectionFor: 10.
"Set up SqueakSSL using the convenience APIs"
ssl := SqueakSSL on: socket.
["Let SqueakSSL handle the client handshake"
ssl connect.
"Verify that the cert is valid"
ssl certState = -1 ifFalse:[ "mac always -1??"
self error: 'The certificate is invalid (code: ', ssl certState,')'.
].
"If the certificate is valid, make sure we're were we wanted to go"
(ssl peerName match: hostName) ifFalse:[
self error: 'Host name mismatch: ', ssl peerName.
].
"Send encrypted data"
ssl sendData:
'GET ', query,' HTTP/1.0', String crlf,
'Host: ', hostName, String crlf,
'Connection: close', String crlf,
String crlf.
"Wait for the response"
^String streamContents:[:s|
[socket isConnected | socket dataAvailable]
whileTrue:[s nextPutAll: ssl receiveData]].
] ensure:[ssl destroy].
! !
More information about the Vm-dev
mailing list