forked from svenvc/zinc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
72 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...Zinc-Character-Encoding-Tests.package/ZnBufferedReadStreamTest.class/instance/testBack.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
tests | ||
testBack | ||
"Check that ZnBufferedReadStream>>#back behaves as expected" | ||
<gtExample> | ||
| stream source | | ||
|
||
"Allocate a buffer larger than the default size (65536)" | ||
self assert: ZnBufferedReadStream basicNew defaultBufferSize < 66000. | ||
source := ByteArray new: 70000. | ||
1 to: 70000 do: [ :i | | ||
source at: i put: i \\ 256 ]. | ||
|
||
stream := ZnBufferedReadStream on: source readStream. | ||
stream position: 1. | ||
self assert: stream peek equals: (source at: 2). | ||
self assert: stream back equals: (source at: 1). | ||
"Position the stream beyond the end of the initial buffer" | ||
stream position: 66000. | ||
self assert: stream peek equals: (source at: 66001). | ||
self assert: stream back equals: (source at: 66000). |
11 changes: 11 additions & 0 deletions
11
...ory/Zinc-HTTP-UnixSocket.package/NetNameResolver.extension/class/addressForSocketPath..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*Zinc-HTTP-UnixSocket | ||
addressForSocketPath: socketPath | ||
"Resolve a socketPath, a Unix Domain Socket, to a SocketAddress" | ||
|
||
| addressSize socketAddress | | ||
self initializeNetwork. | ||
self primGetAddressInfoHost: '' service: socketPath flags: 0 family: 1 type: 0 protocol: 0. | ||
addressSize := self primGetAddressInfoSize. | ||
socketAddress := SocketAddress new: addressSize withAll: 0. | ||
self primGetAddressInfoResult: socketAddress. | ||
^ socketAddress |
3 changes: 3 additions & 0 deletions
3
repository/Zinc-HTTP-UnixSocket.package/NetNameResolver.extension/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name" : "NetNameResolver" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 7 additions & 19 deletions
26
...ry/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/instance/unixSocketOnFile..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,13 @@ | ||
*Zinc-HTTP-UnixSocket | ||
unixSocketOnFile: socketFile | ||
| addressSize socketAddress ipcSocket | | ||
socketFile exists ifFalse: [ | ||
| socketAddress ipcSocket | | ||
socketFile exists ifFalse: [ | ||
ZnMissingUnixSocket new file: socketFile; signal ]. | ||
|
||
NetNameResolver initializeNetwork. | ||
NetNameResolver | ||
primGetAddressInfoHost: '' | ||
service: socketFile fullName | ||
flags: 0 | ||
family: 1 | ||
type: 0 | ||
protocol: 0. | ||
addressSize := NetNameResolver primGetAddressInfoSize. | ||
socketAddress := SocketAddress new: addressSize withAll: 0. | ||
NetNameResolver primGetAddressInfoResult: socketAddress. | ||
|
||
socketAddress := NetNameResolver addressForSocketPath: socketFile fullName. | ||
ipcSocket := Socket newIPC. | ||
ipcSocket ifNil: [ | ||
ZnCannotCreateUnixSocket new file: socketFile; signal ]. | ||
ipcSocket ifNil: [ | ||
ZnCannotCreateUnixSocket new file: socketFile; signal ]. | ||
ipcSocket connectTo: socketAddress. | ||
ipcSocket isConnected ifFalse: [ | ||
ZnCannotConnectUnixSocket new file: socketFile; signal ]. | ||
ipcSocket isConnected ifFalse: [ | ||
ZnCannotConnectUnixSocket new file: socketFile; signal ]. | ||
^ ipcSocket |
16 changes: 7 additions & 9 deletions
16
repository/Zinc-HTTP.package/ZnByteArrayEntity.class/instance/readFrom..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
initialize-release | ||
readFrom: stream | ||
|
||
self contentLength | ||
ifNil: [ | ||
self bytes: (ZnUtils readUpToEnd: stream limit: (ZnCurrentOptions at: #maximumEntitySize)). | ||
self contentLength: self bytes size | ||
] | ||
ifNotNil: [ | byteArray | | ||
|
||
self contentLength: self bytes size ] | ||
ifNotNil: [ | byteArray readCount | | ||
self contentLength > (ZnCurrentOptions at: #maximumEntitySize) | ||
ifTrue: [ ZnEntityTooLarge signal ]. | ||
byteArray := ByteArray ofSize: self contentLength. | ||
self contentLength > ZnUtils streamingBufferSize | ||
readCount := self contentLength > ZnUtils streamingBufferSize | ||
ifTrue: [ ZnUtils streamFrom: stream to: byteArray writeStream size: self contentLength ] | ||
ifFalse: [ stream next: self contentLength into: byteArray ]. | ||
self bytes: byteArray | ||
] | ||
ifFalse: [ stream readInto: byteArray startingAt: 1 count: self contentLength ]. | ||
readCount = self contentLength | ||
ifTrue: [ self bytes: byteArray ] | ||
ifFalse: [ self bytes: (byteArray copyFrom: 1 to: readCount); contentLength: readCount ] ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters