Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hydra

Package Overview
Dependencies
Maintainers
0
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hydra

Double-headed HTTP: allow both clients and servers to issue HTTP requests

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
470
increased by16.92%
Maintainers
0
Weekly downloads
 
Created
Source

Hydra

Double-headed HTTP

Introduction

Hydra works, but is pretty rough and unfinished. The the eventual aim is to make it possible to:

  • Make browser-initiated HTTP requests to the servers.
  • Make server-initiated HTTP requests to browsers.

i.e. both the client and server can push and pull. In particular, HTTP clients running on the server can issue requests like

DELETE http://client16b759c4/item/78

to a HTTP proxy running NodeJS, and have then tunnelled to the browser via a WebSocket.

Status/TODO

At the moment, HTTP requests can be passed back and forth, and there's simple browser-based code for both HTTP servers and HTTP clients. WebSocket-tunnelled HTTP requests can't be chunked or streamed (in either direction), though the client can respond out of order (messages have an id).

This has been tested in Chrome and Firefox on OS X. Chrome supports websockets natively; Firefox requires a Flash "shim".

Installation

For the server:

  1. Download and install NodeJS.

  2. Download and install node.ws.js (a server-side WebSockets implementation for NodeJS) to the parent directory of node-hydra.

  3. Start the server:

    $ node run.js Static Httpd listening at http://127.0.0.1:8080/ Hydra: WebSocket server listening at http://127.0.0.1:8082 Hydra: Httpd server listening at http://127.0.0.1:8081

For the client:

  1. Download and install web-socket-js (an implementation of WebSockets that uses native WebSockets where available, falling back to Flash if not) to the parent directory of node-hydra.
  2. Load http://127.0.0.1:8080/ in Google Chrome.
  3. Open up the JavaScript console. You should see various message, include one giving you your client id.
  4. On the server, you should see a message indicating that a client has connected.

Examples

Client-initiated requests:

  1. In Google Chrome, load http://127.0.0.1:8080/.

  2. In the JavaScript console, enter:

    http.createClient('GET', 'http://beebo.org/', function(res) { console.log(res); });

    This arranges for the server to request http://beebo.org, and return the contents via the WebSocket. The console should show the traffic moving back and forth.

Server-initiated requests:

  1. On the server, enter

    $ export CLIENTID="client611851c0" $ export http_proxy="http://127.0.0.1:8081/" $ curl -s -i -X GET "http://$CLIENTID/" $ curl -s -i -d 'Michael' -X PUT "http://$CLIENTID/" $ curl -s -i -X GET "http://$CLIENTID/"

where `client611851c0` is the client id.
  1. The first command should return Clem, and the second and third should return Michael. This uses the sample server in hello.js.

FAQs

Package last updated on 24 Mar 2017

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