Scoop API

scoop:scoop.http:0.1.0

src/native/http1_events.scoop

Selected production source · src/native/http1_events.scoop

1package scoop.http
3// These two records match the native event's owned field storage on 64-bit targets.
4@CLayout
5internal struct NativeHttpByteStorage(val data: Ptr<Byte>?, val size: ULong, val capacity: ULong)
7@CLayout
8internal struct NativeHttpFieldStorage(
9 val name: NativeHttpByteStorage,
10 val value: NativeHttpByteStorage,
11 val neverIndex: Int
14@CLayout
15internal struct NativeHttpEventView(
16 val info: NativeHttpEventInfo,
17 val first: NativeHttpBytes,
18 val second: NativeHttpBytes,
19 val fields: Ptr<NativeHttpFieldStorage>?,
20 val fieldCount: Long,
21 val next: ULong
24@GCLeaf
25@Extern(name = "scoop_http1_take_events")
26internal fun http1TakeEvents(handle: ULong): ULong
28@GCLeaf
29@Extern(name = "scoop_http_event_view")
30internal fun httpEventView(handle: ULong): NativeHttpEventView
32@Extern(name = "scoop_http_event_batch_free")
33internal fun httpEventBatchFree(handle: ULong)
35@Unsafe
36internal fun httpEventFields(view: NativeHttpEventView): Array<HttpField> =
37 Array<HttpField>(view.fieldCount) {
38 index -> @Unsafe
39 {
40 val field = view.fields!!.load(index)
41 return@Array HttpField(
42 httpBytes(NativeHttpBytes(field.name.data, field.name.size.toLong())),
43 httpBytes(NativeHttpBytes(field.value.data, field.value.size.toLong())),
44 field.neverIndex != 0
45 )
46 }
47 }