class Net::PTTH
  IncomingRequest = Struct.new(:method, :path, :headers, :body) do
    def to_env
      env = {
        "PATH_INFO" => path,
        "SCRIPT_NAME" => "",
        "rack.input" => StringIO.new(body || ""),
        "REQUEST_METHOD" => method,
      }

      env["CONTENT_LENGTH"] = body.length unless body.nil?

      env.merge!(headers) if headers
    end
  end
end

class Net::PTTH
  IncomingRequest = Struct.new(:method, :path, :headers, :body) do
    def to_env
      env = {
        "PATH_INFO" => path,
        "SCRIPT_NAME" => "",
        "rack.input" => StringIO.new(body || ""),
        "REQUEST_METHOD" => method,
      }

      env["CONTENT_LENGTH"] = body.length unless body.nil?

      env.merge!(headers) if headers

      env
    end
  end
end

Make sure env is always returned
Make sure env is always returned

If headers is nil here, the method previously returned nil.
