1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| | # -*- encoding: binary -*-
# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> et. al.
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require_relative 'wbuf_common'
# we only use this for buffering the tiniest responses (which are already
# strings in memory and a handful of bytes).
#
# "HTTP", "/1.1 "
# "HTTP/1.1 100 Continue\r\n\r\n"
# "100 Continue\r\n\r\nHTTP/1.1 "
#
# This is very, very rarely triggered.
# 1) check_client_connection is enabled
# 2) the client sent an "Expect: 100-continue" header
#
# Most output buffering goes through
# the normal Yahns::Wbuf class which uses a temporary file as a buffer
# (suitable for sendfile())
class Yahns::WbufStr # :nodoc:
include Yahns::WbufCommon
def initialize(str, next_state)
@str = str
@next = next_state # :ccc_done, :r100_done
end
def wbuf_flush(client)
case rv = client.kgio_trywrite(@str)
when String
@str = rv
when :wait_writable, :wait_readable
return rv
when nil
return @next
end while true
end
end
|