Manual
Streams and files
PSR-7 streams, multipart bodies, and file functions that let others run.
Introduction#
phasync's PSR-7 implementation (Request, Response, ServerRequest, Uri) is the same shape as any other, with StringStream, BufferedStream and UnbufferedStream for the body and MultipartStream for a multipart/form-data upload. A file function such as fread() or fwrite() blocks the process on its own; see Waiting and timeouts for what lets it wait without doing that instead.
Examples#
- All examples of this topic – 13 with their output.
Reference#
DeadmanException– The writer of a StringBuffer exited without ending it: a read throws this once the buffered data is read.BufferedStream– A seekable PSR-7 stream for a body that is still being produced, kept in memory and then in a temporary file.StringStream– A readable, seekable PSR-7 stream over a string that is known in full.UnbufferedStream– A PSR-7 stream for a body that is still being produced, read once and in order.UploadedFile– A PSR-7 file uploaded with a request.StringBuffer– A buffer of streamed bytes that one coroutine fills and another reads, for parsing protocols that arrive in frames.MultipartStream– A multipart/form-data request body built from a nested array of fields.MultipartStreamInterface– A request body stream that carries a multipart/form-data payload.