Skip to content

Mask/evma_httpserver

This branch is 12 commits ahead of, 19 commits behind eventmachine/evma_httpserver:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b8388e3 · Oct 4, 2011

History

33 Commits
Dec 19, 2008
Oct 4, 2011
Apr 15, 2011
Apr 15, 2011
Jan 31, 2011
Jan 31, 2011
Jan 31, 2011
Jun 1, 2011
Jan 31, 2011

Repository files navigation

= eventmachine_httpserver

== EM::HttpServer vs Thin

     +careo | is there a 25 word version of how it differs from thin?
      +tmm1 | good question.. its probably faster, but only because it doesn't have a real http parser like thin
  +wyhaines | It is faster.  It's more of an nginx style parser than the mongrel, grammar based parser.
     +careo | so perhaps a better fit for putting an http interface on top of a bunch of already-evented code?
  +wyhaines | careo: It depends.  There are very valid arguments for using an RFC-compliant parser a lot of the time.
  +wyhaines | But, yeah, sometimes being strictly RFC compliant isn't something that you care about.

== Usage example

  require 'eventmachine'
  require 'evma_httpserver'

  class MyHttpServer < EM::Connection
    include EM::HttpServer

     def post_init
       super

       # faster if you don't need evironment variables (CGI methods)
       self.no_environment_strings

       # max length of the POST content
       self.max_content_length = 10_000_000
     end

    def process_http_request
      # the http request details are available via the following instance variables:
      #   @http_protocol
      #   @http_request_method
      #   @http_cookie
      #   @http_if_none_match
      #   @http_content_type
      #   @http_path_info
      #   @http_request_uri
      #   @http_query_string
      #   @http_post_content
      #   @http_headers

      response = EM::DelegatedHttpResponse.new(self)
      response.status = 200
      response.content_type 'text/html'
      response.content = '<center><h1>Hi there</h1></center>'
      response.send_response
    end
  end

  EM.run{
    EM.start_server '0.0.0.0', 8080, MyHttpServer
  }

About

An evented http server built on top of eventmachine

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 53.6%
  • C++ 46.4%