# WEBrick SSL output size limit?

**URL:** <https://www.ruby-forum.com/t/webrick-ssl-output-size-limit/171428>\
**Category:** Ruby\
**Created:** [July 2, 2009, 11:15am UTC](https://www.ruby-forum.com/t/webrick-ssl-output-size-limit/171428 "2009-07-02T11:15:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skywriter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@skywriter](https://www.ruby-forum.com/u/skywriter)\
**Post date:** [July 2, 2009, 11:15am UTC](https://www.ruby-forum.com/t/webrick-ssl-output-size-limit/171428/1 "2009-07-02T11:15:58Z")

</div>

Greetings, dear sirs!

I am developing a tiny server software that provides the clients with  
certain XML documents via HTTPS. I am using WEBrick applet for this in  
the following way:

def do\_GET(req, res)  
company\_id = do\_auth(req, res)  
res.body = get\_the\_xml\_body(company\_id)  
res[‘Content-Type’] = “text/xml”  
res[‘X-Company-Id’] = company\_id  
res.keep\_alive = false  
puts “All internal request processing is finished. Body length  
#{res.body.length}, size #{res.body.size}, byte size  
#{res.body.bytesize}”  
end

Everything works fine until the document size exceeds 16k. When this  
happens, the client gets only 16383 bytes of the XML. WEBrick log is the  
following:

[2009-07-02 13:10:06] INFO DirectPagerServer#start: pid=22528 port=2000  
All internal request processing is finished. Body length 15612, size  
15612, byte size 17496  
::ffff:172.23.0.231 - user [02/Jul/2009:13:10:18 MSD] “GET  
/data/?nowait=1 HTTP/1.1” 200 17496

It seems that everything in WEBrick goes fine until the data hits  
SSLSocket, which is used to transfer all the data to the client. At this  
point it gets cut. I’ve tried setting “res.keep\_alive = true”, this  
makes the client hit timeout, since it never gets all the promised 17496  
bytes of data thus having no reason to finish the connection.

I’ve heard of SSL message limitation of 16k. So I’ve tried setting  
WEBrick buffer size to something lower:

WEBrick::Config::HTTP[:InputBufferSize] =  
WEBrick::Config::HTTP[:OutputBufferSize] = 1024

And then turning on chunked with “res.chunked = true” to force WEBrick  
buffer usage. This eliminated hangup problem even with keep\_alive on,  
but produces garbled documents in the end.

Has anybody faced this problem? Any ideas?

Thank you in advance!

Sincerely,  
Ivan.
