Skip to content

Commit 92c1447

Browse files
requests implementation in terms of streams
1 parent eb53d25 commit 92c1447

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

libraries/common/io/requests.effekt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,17 @@ namespace plain {
533533
}
534534
}
535535
}
536+
537+
/// Implements the `request` function using an implementation in Effekt.
538+
/// `read`s and `emit`s from/to a connection (provided from elsewhere).
539+
def request[R]{ body: => Unit / RequestBuilder }{ res: {ResponseReader} => R }: R / { emit[Byte], read[Byte], Exception[RequestError] } = {
540+
constructRequest{ body }
541+
try {
542+
parseResponse{res}
543+
} with Exception[WrongFormat] {
544+
def raise(e, msg) = do raise(RequestError(), "Malformed response: " ++ msg)
545+
}
546+
}
536547
}
537548

538549

0 commit comments

Comments
 (0)