{"id":30211268,"url":"https://github.com/mons/anyevent-http-server-ii","last_synced_at":"2025-08-13T20:35:40.339Z","repository":{"id":6511021,"uuid":"7751732","full_name":"Mons/AnyEvent-HTTP-Server-II","owner":"Mons","description":"Fast Asynchronous HTTP/1.1 Server","archived":false,"fork":false,"pushed_at":"2023-03-15T13:16:35.000Z","size":186,"stargazers_count":36,"open_issues_count":5,"forks_count":16,"subscribers_count":17,"default_branch":"master","last_synced_at":"2023-05-05T05:12:29.214Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mons.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-22T12:09:38.000Z","updated_at":"2023-03-15T19:26:43.000Z","dependencies_parsed_at":"2023-01-11T17:01:12.896Z","dependency_job_id":null,"html_url":"https://github.com/Mons/AnyEvent-HTTP-Server-II","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"purl":"pkg:github/Mons/AnyEvent-HTTP-Server-II","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-HTTP-Server-II","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-HTTP-Server-II/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-HTTP-Server-II/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-HTTP-Server-II/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mons","download_url":"https://codeload.github.com/Mons/AnyEvent-HTTP-Server-II/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-HTTP-Server-II/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270305853,"owners_count":24562110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-13T20:34:24.712Z","updated_at":"2025-08-13T20:35:40.318Z","avatar_url":"https://github.com/Mons.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n    AnyEvent::HTTP::Server - AnyEvent HTTP/1.1 Server\n\nSYNOPSIS\n        use AnyEvent::HTTP::Server;\n        my $s = AnyEvent::HTTP::Server-\u003enew(\n        host =\u003e '0.0.0.0',\n        port =\u003e 80,\n        cb =\u003e sub {\n          my $request = shift;\n          my $status  = 200;\n          my $content = \"\u003ch1\u003eReply message\u003c/h1\u003e\";\n          my $headers = { 'content-type' =\u003e 'text/html' };\n          $request-\u003ereply($status, $content, headers =\u003e $headers);\n        }\n        );\n        $s-\u003elisten;\n\n        ## you may also prefork on N cores:\n\n        # fork() ? next : last for (1..$N-1);\n\n        ## Of course this is very simple example\n        ## don't use such prefork in production\n\n        $s-\u003eaccept;\n\n        my $sig = AE::signal INT =\u003e sub {\n        warn \"Stopping server\";\n        $s-\u003egraceful(sub {\n            warn \"Server stopped\";\n            EV::unloop;\n        });\n        };\n\n        EV::loop;\n\nDESCRIPTION\n    AnyEvent::HTTP::Server is a very fast asynchronous HTTP server written\n    in perl. It has been tested in high load production environments and may\n    be considered both fast and stable.\n\n    One can easily implement own HTTP daemon with AnyEvent::HTTP::Server and\n    Daemond::Lite module, both found at \u003chttps://github.com/Mons\u003e\n\n    This is a second verson available as AnyEvent-HTTP-Server-II. The first\n    version is now obsolette.\n\nHANDLING REQUEST\n    You can handle HTTP request by passing cb parameter to\n    AnyEvent::HTTP::Server-\u003enew() like this:\n\n      my $dispatcher = sub {\n        my $request = shift;\n        #... Request processing code goes here ...\n        1;\n      };\n\n      my $s = AnyEvent::HTTP::Server-\u003enew( host =\u003e '0.0.0.0', port =\u003e 80, cb =\u003e $dispatcher,);\n\n    $dispatcher coderef will be called in a list context and it's return\n    value should resolve to true, or request processing will be aborted by\n    AnyEvent:HTTP::Server.\n\n    One able to process POST requests by returning specially crafted hash\n    reference from cb parameter coderef ($dispatcher in out example). This\n    hash must contain the form key, holding a code reference. If\n    conetnt-encoding header is application/x-www-form-urlencoded, form\n    callback will be called.\n\n      my $post_action = sub {\n        my ( $request, $form ) = @_;\n        $request-\u003ereply(\n          200, # HTTP Status\n          \"You just send long_data_param_name value of $form-\u003e{long_data_param_name}\",  # Content\n          headers=\u003e { 'content-type' =\u003c 'text/plain'}, # Response headers\n        );\n      }\n\n      my $dispatcher = sub {\n        my $request = shift;\n\n        if ( $request-\u003eheaders-\u003e{'content-type'} =~ m{^application/x-www-form-urlencoded\\s*$} ) {\n          return {\n        form =\u003e sub {\n          $cb-\u003e( $request, $post_action);\n        },\n          };\n        } else {\n          # GET request processing\n        } \n\n      };\n\n      my $s = AnyEvent::HTTP::Server-\u003enew( host =\u003e '0.0.0.0', port =\u003e 80, cb =\u003e $dispatcher,);\n\nEXPORT\n      Does not export anything\n\nSUBROUTINES/METHODS\n  new - create HTTP Server object\n      Arguments to constractor should be passed as a key=\u003evalue list, for example\n\n        my $s = AnyEvent::HTTP::Server-\u003enew(\n        host =\u003e '0.0.0.0',\n        port =\u003e 80,\n        cb   =\u003e sub {\n            my $req = shift;\n            return sub {\n            my ($is_last, $bodypart) = @_;\n            $r-\u003ereply(200, \"\u003ch1\u003eReply message\u003c/h1\u003e\", headers =\u003e { 'content-type' =\u003e 'text/html' });\n            }\n        }\n        );\n\n   host\n      Specify interfaces to bind a listening socket to\n      Example: host =\u003e '127.0.0.1'\n\n   port\n      Listen on this port\n      Example: port =\u003e 80\n\n   cb\n      This coderef will be called on incoming request\n      Example: cb =\u003e sub {\n        my $request = shift;\n        my $status  = 200;\n        my $content = \"\u003ch1\u003eReply message\u003c/h1\u003e\";\n        my $headers = { 'content-type' =\u003e 'text/html' };\n        $request-\u003ereply($status, $content, headers =\u003e $headers);\n      }\n\n      The first argument to callback will be request object (AnyEvent::HTTP::Server::Req).\n\n  listen - bind server socket to host and port, start listening for connections\n      This method has no arguments.\n\n      This method is commonly called from master process before it forks.\n\n      Errors in host and port may result in exceptions, so you probably want to eval this call.\n\n  accept - start accepting connections\n      This method has no arguments.\n\n      This method is commonly called in forked children, which serve incoming requests.\n\n  noaccept - stop accepting connections (while still listening on a socket)\n      This method has no arguments.\n\n  graceful - Stop accepting new connections and gracefully shut down the server\n      Wait until all connections will be handled and execute supplied coderef after that.\n      This method can be useful in signal handlers.\n\n  set_favicon - change default favicon.ico\n      The only argument is a scalar, containing binary representation of icon.\n      Favicon will have content type set to 'image/x-icon'\n\nRESOURCES\n    *   GitHub repository\n\n        \u003chttp://github.com/Mons/AnyEvent-HTTP-Server-II\u003e\n\nACKNOWLEDGEMENTS\n    *   Thanks to Marc Lehmann for AnyEvent\n\n    *   Thanks to Robin Redeker for AnyEvent::HTTPD\n\nAUTHOR\n    Mons Anderson, \u003cmons@cpan.org\u003e\n\nLICENSE\n    This program is free software; you can redistribute it and/or modify it\n    under the terms of either: the GNU General Public License as published\n    by the Free Software Foundation; or the Artistic License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmons%2Fanyevent-http-server-ii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmons%2Fanyevent-http-server-ii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmons%2Fanyevent-http-server-ii/lists"}