Coder Social home page Coder Social logo

sse's Introduction

SSE

This package contains a native client for HTTP server sent events.

The sse client is geared to the specification as per http://www.w3.org/TR/eventsource, but does not follow it completely. See below for known differences.

sse: listening to an SSE stream

sse connects to an URL, where it expects a stream of server sent events. On each incoming event it runs a command specified on the command line, passing in event data via process environment.

sse [ <options> ] URL [ <command> ... ]

On each incoming event sse runs command, with any additional arguments passed in at the command line.

Options include:

  -a <ca>      ... set PEM CA file
  -c <cert>    ... set PEM certificate file
  -i           ... insecure: allow HTTP and non-certified HTTPS connections
  -l <limit>   ... limit number of events
  -v           ... be verbose; can be set multiple times

The event's data attribute is written to the command's standard input. All other event attributes are passed via environment variables (SSE_EVENT, SSE_ID, and so on.)

If a SSE "reply" attribute is set, sse also posts the command's result to the URL specified there.

sse security

By default, sse only accepts HTTPS connections. It verifies the complete certificate chain and the host name. To run against HTTP and insecure HTTPS connections use the -i parameter.

If you need to use CA files different from the system default, use the -a and -c options.

When sse starts a subcommand, it limits the subcommand's output to ~120 kByte. This should limit sse's potential memory usage; however, you should use softlimit (http://cr.yp.to/daemontools/softlimit.html) or a similar tool to limit resource usage for sse and its child processes.

Issues and limitations.

sse violates the eventsource specifications in a number of ways. They

  • When evaluating an event stream sse does not decode anything as UTF-8, and does not do any error checking on this.
  • sse does not deal with LF characters in its input.
  • sse does not ignore any field names (There is a compile time limit on possible fields, though.)
  • sse ignores lines without a colon, instead of setting a event field with no value
  • sse resets the "id" between events
  • sse does not evaluate "retry" fields

In addition, if an event has a "reply" field, and that field contains an URL, sse sends the result of the command execution via HTTP(S) POST to that URL.

Remember: sse was extracted from a communication suite intended to run on mobile devices. As such, it implements some things differently from the specs. It should still be able to listen to any conforming SSE stream, though (with the notable exception of dealing with LF characters).

post: listening to an SSE stream

For development purposes this package also contains a post binary, which one can use to POST some data to a URL.

post [ <options> ] URL [ <data> ]

Options include:

-a <ca>     ... set PEM CA file
-c <cert>   ... set PEM certificate file
-i          ... insecure: allow HTTP and non-certified HTTPS connections
-v          ... be verbose; can be set multiple times

Usage examples:

echo -n foo | post http://some.where/bar
post http://some.where/bar foo

But really post does not offer any advantages over clients such as curl or wget.

Building

make

builds the binaries ./bin/sse and ./bin/post.

sse's People

Contributors

radiospiel avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.