+ defined($self->{rbuf}) || exists($self->{env}) || defined($self->{wbuf})
+}
+
+# runs $cb on the next iteration of the event loop at earliest
+sub next_step {
+ my ($self, $cb) = @_;
+ return unless exists $self->{sock};
+ $self->requeue if 1 == push(@{$self->{wbuf}}, $cb);
+}
+
+# Chunked and Identity packages are used for writing responses.
+# They may be exposed to the PSGI application when the PSGI app
+# returns a CODE ref for "push"-based responses
+package PublicInbox::HTTP::Chunked;
+use strict;
+
+sub write {
+ # ([$http], $buf) = @_;
+ PublicInbox::HTTP::chunked_write($_[0]->[0], $_[1])
+}
+
+sub close {
+ # $_[0] = [$http, $alive]
+ PublicInbox::HTTP::response_done(@{$_[0]});
+}
+
+package PublicInbox::HTTP::Identity;
+use strict;
+our @ISA = qw(PublicInbox::HTTP::Chunked);
+
+sub write {
+ # ([$http], $buf) = @_;
+ PublicInbox::HTTP::identity_write($_[0]->[0], $_[1]);