cacao 0.3.2

Cacao (CORS Access-Control-Allow-Origin) Proxy #

Cacao is a localhost Cross-Origin (CORS) proxy. It allows Javascript running in a web browser to access a remote HTTP resource without cross-origin restrictions. It runs on several different platforms, and essentially works by adding a Access-Control-Allow-Origin: * header to an HTTP response.

IP Camera Streaming #

The main use case is to access a remote streaming MJPEG URL published by an IP Camera, via an <img> tag pointing to Cacao. Without Cacao, this image data is usually marked as cross-origin, and therefore cannot be used as the source for a WebRTC stream.

With Cacao, an <img crossorigin> can be copied to a <canvas> and then (since CORS is allowed) sent by the browser via WebRTC. Try loading the (MJPEG sample)[static/mjpeg.html] in your browser to experiment with this capability, and to understand the vanilla Javascript source code.

The Mediasoup Broadcast Example will eventually add support for using Cacao to request media to stream.

Usage #

Cacao Proxy #

Cacao can be run as a localhost proxy server on Linux (and other Unix-like), MacOS, and Windows.

Download a binary package from the Cacao releases, if you just want to use the proxy (and not change its code).

If you are a developer, you can run Cacao directly from sources in this project, but you will first need to install the Dart SDK:

$ dart --version
$ bin/cacao --help

Cacao Proxy App #

See the Cacao Proxy App for a graphical app for controlling a builtin Cacao proxy on your mobile device.

Michael FIG, 2018-12-05

0.3.2 #

  • Implement ../PATH and ./PATH URLs relative to Cacao's program file.
  • Use MJPEG DataLen header if Content-Length doesn't exist.
  • Make serveFile send 404's and directory index based on the filesystem contents.
  • Send no-cache headers from serveHttp.

0.3.1 #

  • Fix HTTP proxy connection leak.
  • Improve file proxy error messages.
  • Get mjpeg.html working on Firefox and Chrome without relying on nonstandard behaviour.

0.3.0 #

  • Crib pub run grinder package from dart-sass.
  • Clean up serve API in preparation for UI development.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  cacao: ^0.3.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:cacao/cacao.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health issues and suggestions

Document public APIs. (-1 points)

8 out of 8 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/io/serveHttp.dart. (-2.96 points)

Analysis of lib/src/io/serveHttp.dart reported 6 hints, including:

line 5 col 18: Unnecessary new keyword.

line 8 col 3: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 29 col 7: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 32 col 8: Dead code.

line 33 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

Fix bin/cacao.dart. (-1.49 points)

Analysis of bin/cacao.dart reported 3 hints:

line 20 col 18: Unnecessary new keyword.

line 48 col 19: Unnecessary new keyword.

line 49 col 14: Unnecessary new keyword.

Fix lib/src/io/serveFile.dart. (-1 points)

Analysis of lib/src/io/serveFile.dart reported 2 hints:

line 19 col 14: Unnecessary new keyword.

line 27 col 46: Unnecessary new keyword.

Fix additional 3 files with analysis or formatting issues. (-1 points)

Additional issues in the following files:

  • lib/src/findUri.dart (1 hint)
  • lib/src/io/serve.dart (1 hint)
  • lib/src/resolve.dart (Run dartfmt to format lib/src/resolve.dart.)

Maintenance suggestions

Package is getting outdated. (-17.53 points)

The package was last published 61 weeks ago.

The package description is too short. (-14 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and cacao.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0-dev <3.0.0
args ^1.5.1 1.5.2
mime ^0.9.6+2 0.9.6+3
path ^1.6.2 1.6.4
Dev dependencies
archive ^2.0.0
grinder ^0.8.0
http ^0.12.0
meta ^1.1.0
pub_semver ^1.4.0
test ^1.0.0
yaml ^2.1.0