Help with HTTP Intercepting Proxy in Ruby?

I have the beginnings of an HTTP Intercepting Proxy written in Ruby (see
attachment).

This simple proxy that I made parses the destination out of the HTTP
request, then reads the HTTP response and performs logic based on
special HTML tags. The proxy works for the most part, but seems to have
trouble dealing with binary data and HTTPS connections.

How can I fix these problems?