New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

thin_async

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thin_async

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Thin Asynchronous Response API

A nice wrapper around Thin's obscure async callback used to send response body asynchronously. Which means you can send the response in chunks while allowing Thin to process other requests.

Crazy delicious with em-http-request for file upload, image processing, proxying, etc.

WARNING

You should not use long blocking operations (Net::HTTP or slow shell calls) with this as it will prevent the EventMachine event loop from running and block all other requests.

Usage

Inside your Rack app #call(env):

Thin::AsyncResponse.perform(env) do |response|
  response.status = 201
  response.headers["X-Muffin-Mode"] = "ACTIVATED!"

  response << "this is ... "

  EM.add_timer(1) do
    # This will be sent to the client 1 sec later without blocking other requests.
    response << "async!"
    response.done
  end
end

See example/ dir for more.

(c) macournoyer

FAQs

Package last updated on 03 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc