Function cgid::set_header [] [src]

pub fn set_header(line: String, content_length: &mut usize) -> Result<(), HTTP>

Sets an environment variable parsed from line

line must contain a key value pair separated by a : (colon + optional trailing spaces). "key: value"

The environment variable name will be key: prefixed by 'HTTP_', converted to upper_case, and - replaced with _.

The value will have leading spaces removed but is otherwise unmodified.

Examples

use cgid;
use std::env;

let mut content_length: usize = 0;
let result = cgid::set_header("key: value".to_string(), &mut content_length);

assert!(result.is_ok());
assert_eq!(env::var("HTTP_KEY").unwrap(), "value");