<commit_before># httpcli

**httpcli** is an app for sending API commands to the EMS through the command line.

## Installation

1. EMS is required to run with the code.
   - [Installation of EMS on Ubuntu](http://docs.evostream.com/ems_quick_start_guide/quick_start_guide_for_linux#baptyum-installation)

2. Crystal language is required to run the code or build the binary.
   Crystal is based on Ruby but is compiled and runs faster.
   - [Installation of Crystal on Ubuntu](http://crystal-lang.org/docs/installation/on_debian_and_ubuntu.html)

3. The binary can also be downloaded for Ubuntu 16.04 (64-bit).

   ```bash
   $ unzip bin\release-1_0_0-ubuntu-16_04-64\httpcli.zip
   ```

## Usage

1. Start EMS

   ```bash
   $ sudo service evostreamms start
   ```

2. Build httpcli binary
   
   ```bash
   $ crystal build httpcli.cr
   ```

3. Run httpcli

   ```bash
   $ ./httpcli version
   Send to EMS 'version'
   Received from EMS:
   {"data":{"banner":"EvoStream Media Server (www.evostream.com) version 1.7.0 build 4283 with hash: 395ff5e220ea7311adf3fca70960fb30c7785d34 - PacMan|m| - (built for Ubuntu-14.04-x86_64 on 2016-01-27T10:00:15.000)","branchName":"","buildDate":"2016-01-27T10:00:15.000","buildNumber":"4283","codeName":"PacMan|m|","hash":"395ff5e220ea7311adf3fca70960fb30c7785d34","releaseNumber":"1.7.0"},"description":"Version","status":"SUCCESS"}

   $ ./httpcli pullstream uri=rtmp://streaming.cityofboston.gov/live/cable localstreamname=mystream
   Received from EMS:
   {"data":{"audioCodecBytes":"","configId":1,"emulateUserAgent":"EvoStream Media Server (www.evostream.com) player","forceTcp":false,"httpProxy":"","isAudio":true,"keepAlive":true,"localStreamName":"mystream","operationType":1,"pageUrl":"","ppsBytes":"","rangeEnd":-1,"rangeStart":-2,"rtcpDetectionInterval":10,"sendRenewStream":false,"spsBytes":"","ssmIp":"","swfUrl":"","tcUrl":"","tos":256,"ttl":256,"uri":{"document":"cable","documentPath":"\/live\/","documentWithFullParameters":"cable","fullDocumentPath":"\/live\/cable","fullDocumentPathWithParameters":"\/live\/cable","fullParameters":"","fullUri":"rtmp:\/\/streaming.cityofboston.gov\/live\/cable","fullUriWithAuth":"rtmp:\/\/streaming.cityofboston.gov\/live\/cable","host":"streaming.cityofboston.gov","ip":"172.16.31.10","originalUri":"rtmp:\/\/streaming.cityofboston.gov\/live\/cable","parameters":{},"password":"","port":1935,"portSpecified":false,"scheme":"rtmp","userName":""}},"description":"Stream rtmp:\/\/streaming.cityofboston.gov\/live\/cable enqueued for pulling","status":"SUCCESS"}
   ```

## Downloads

- See the [download](https://github.com/EvoStream/evostream_addons/tree/master/crystal_samples/httpcli/download) directory for compiled binaries of httpcli.

## Development

- The source code is provided for demonstration purposes only. It can be found on GitHub:

  https://github.com/EvoStream/evostream_addons/tree/master/crystal_samples/httpcli<commit_msg>Update examples in httpcli README<commit_after># httpcli

**httpcli** is an app for sending API commands to the EMS through the command line.

## Installation

1. EMS is required to run with the code.
   - [Installation of EMS on Ubuntu](http://docs.evostream.com/ems_quick_start_guide/quick_start_guide_for_linux#baptyum-installation)

2. Crystal language is required to run the code or build the binary.
   Crystal is based on Ruby but is compiled and runs faster.
   - [Installation of Crystal on Ubuntu](http://crystal-lang.org/docs/installation/on_debian_and_ubuntu.html)

3. The binary can also be downloaded for Ubuntu 16.04 (64-bit).

   ```bash
   $ unzip bin\release-1_0_0-ubuntu-16_04-64\httpcli.zip
   ```

## Usage

1. Start EMS

   ```bash
   $ sudo service evostreamms start
   ```

2. Build httpcli binary
   
   ```bash
   $ crystal build httpcli.cr
   ```

3. Run httpcli

   ```bash
   $ ./httpcli version
   Send to EMS 'version'
   Sent via HTTP 'http://localhost:7777/version?params='
   Received from EMS:
   {
     "data": {
       "banner": "EvoStream Media Server (www.evostream.com) version 1.7.1 build 4491 with hash: 64b305253110afc4acd5aeaf87f0a0b0f9b53526 - PacMan|m| - (built for Ubuntu-16.04-x86_64 on 2016-06-17T10:05:48.000)",
       "branchName": "",
       "buildDate": "2016-06-17T10:05:48.000",
       "buildNumber": "4491",
       "codeName": "PacMan|m|",
       "hash": "64b305253110afc4acd5aeaf87f0a0b0f9b53526",
       "releaseNumber": "1.7.1"
     },
     "description": "Version",
     "status": "SUCCESS"
   }
   ```

   ```bash
   $ ./httpcli pullstream uri=rtmp://streaming.cityofboston.gov/live/cable localstreamname=mystream
   Send to EMS 'pullstream uri=rtmp://streaming.cityofboston.gov/live/cable localstreamname=mystream'
   Sent via HTTP 'http://localhost:7777/pullstream?params=dXJpPXJ0bXA6Ly9zdHJlYW1pbmcuY2l0eW9mYm9zdG9uLmdvdi9saXZlL2NhYmxlIGxvY2Fsc3RyZWFtbmFtZT1teXN0cmVhbTE='
   Received from EMS:
   {
     "data": {
       "audioCodecBytes": "",
       "configId": 5,
       "emulateUserAgent": "EvoStream Media Server (www.evostream.com) player",
       "forceTcp": false,
       "httpProxy": "",
       "isAudio": true,
       "keepAlive": true,
       "localStreamName": "mystream",
       "operationType": 1,
       "pageUrl": "",
       "ppsBytes": "",
       "rangeEnd": -1,
       "rangeStart": -2,
       "rtcpDetectionInterval": 10,
       "sendRenewStream": false,
       "spsBytes": "",
       "ssmIp": "",
       "swfUrl": "",
       "tcUrl": "",
       "tos": 256,
       "ttl": 256,
       "uri": {
         "document": "cable",
         "documentPath": "/live/",
         "documentWithFullParameters": "cable",
         "fullDocumentPath": "/live/cable",
         "fullDocumentPathWithParameters": "/live/cable",
         "fullParameters": "",
         "fullUri": "rtmp://streaming.cityofboston.gov/live/cable",
         "fullUriWithAuth": "rtmp://streaming.cityofboston.gov/live/cable",
         "host": "streaming.cityofboston.gov",
         "ip": "172.16.31.10",
         "originalUri": "rtmp://streaming.cityofboston.gov/live/cable",
         "parameters": {},
         "password": "",
         "port": 1935,
         "portSpecified": false,
         "scheme": "rtmp",
         "userName": ""
       }
     },
     "description": "Stream rtmp://streaming.cityofboston.gov/live/cable enqueued for pulling",
     "status": "SUCCESS"
   }
   ```

   ```bash
   $ ./httpcli pullstream uri=rtmp://streaming.cityofboston.gov/live/cable localstreamname=mystream
   Send to EMS 'pullstream uri=rtmp://streaming.cityofboston.gov/live/cable localstreamname=mystream'
   Sent via HTTP 'http://localhost:7777/pullstream?params=dXJpPXJ0bXA6Ly9zdHJlYW1pbmcuY2l0eW9mYm9zdG9uLmdvdi9saXZlL2NhYmxlIGxvY2Fsc3RyZWFtbmFtZT1teXN0cmVhbQ=='
   Received from EMS:
   {
     "data": null,
     "description": "Stream name mystream already taken",
     "status": "FAIL"
   }
   ```

## Downloads

- See the [download](https://github.com/EvoStream/evostream_addons/tree/master/crystal_samples/httpcli/download) directory for compiled binaries of httpcli.

## Development

- The source code is provided for demonstration purposes only. It can be found on GitHub:

  https://github.com/EvoStream/evostream_addons/tree/master/crystal_samples/httpcli
{'fraction_non_alphanumeric': 0.15507947477539738, 'fraction_numerical': 0.04754664823773324, 'mean_word_length': 3.919102651257648, 'pattern_counts': {'":': 107, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4102150', 'n_tokens_mistral': 2757, 'n_tokens_neox': 2469, 'n_words': 462}