<commit_before>extern crate hyper;
extern crate rustc_serialize;

use std::env;
use std::process;
use std::io::Read;
use rustc_serialize::json;
use hyper::header::{Headers, Authorization, Basic, ContentType};
use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
use hyper::Client;

static VALID_COMMANDS: &'static [ &'static str ] = &["version"];

#[derive(RustcDecodable, RustcEncodable)]
struct RequestBody {
  jsonrpc: String,
  method: String,
  id: u8
}

// TODO: Check for proper error code to exit with. 
fn exit_with_error(message: &str) {
    println!("ERR: {}", message);
    process::exit(1);
}

fn run(command: &str) {
    if !&VALID_COMMANDS.contains(&command) {
        exit_with_error(&format!("Invalid command: {}", command));
    }
    
    println!("Executing command: {}", command);
    
    let body = RequestBody {
        jsonrpc: "2.0".to_string(), 
        method:  "JSONRPC.Version".to_string(),
        id: 1
    };

    let client = Client::new();
    let mut headers = Headers::new();
    headers.set(ContentType(Mime(TopLevel::Application, SubLevel::Json, vec![(Attr::Charset, Value::Utf8)])));
    headers.set(
        Authorization(
            Basic { 
                username: "xbmc".to_owned(), 
                password: Some("<PASSWORD>".to_owned())
            }<commit_msg>Reduced content type, please.<commit_after>extern crate hyper;
extern crate rustc_serialize;

use std::env;
use std::process;
use std::io::Read;
use rustc_serialize::json;
use hyper::header::{Headers, Authorization, Basic, ContentType};
use hyper::Client;

static VALID_COMMANDS: &'static [ &'static str ] = &["version"];

#[derive(RustcDecodable, RustcEncodable)]
struct RequestBody {
  jsonrpc: String,
  method: String,
  id: u8
}

// TODO: Check for proper error code to exit with. 
fn exit_with_error(message: &str) {
    println!("ERR: {}", message);
    process::exit(1);
}

fn run(command: &str) {
    if !&VALID_COMMANDS.contains(&command) {
        exit_with_error(&format!("Invalid command: {}", command));
    }
    
    println!("Executing command: {}", command);
    
    let body = RequestBody {
        jsonrpc: "2.0".to_string(), 
        method:  "JSONRPC.Version".to_string(),
        id: 1
    };

    let client = Client::new();
    let mut headers = Headers::new();
    headers.set(ContentType::json());
    headers.set(
        Authorization(
            Basic { 
                username: "xbmc".to_owned(), 
                password: Some("<PASSWORD>".to_owned())
            }
{'fraction_non_alphanumeric': 0.15680825724493846, 'fraction_numerical': 0.004366812227074236, 'mean_word_length': 3.3003412969283277, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4245908', 'n_tokens_mistral': 811, 'n_tokens_neox': 808, 'n_words': 186}