ssavvides / sgx-https

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sgx-https

An HTTP/HTTPS client for use inside of SGX enclaves created using the Fortanix EDP.

Example

A get request with a text response:

fn main() {
    let response_body = sgx_https::get("https://example.com")
        .unwrap()
        .text()
        .unwrap();
    println!("{}", response_body);
}

A get request with a json response:

use std::collections::HashMap;

fn main() {
    let response_body: HashMap<String, String> = sgx_https::get("https://httpbin.org/ip")
        .unwrap()
        .json()
        .unwrap();
    println!("{:?}", response_body);
}

Request customization:

use std::collections::HashMap;

fn main() {
    let response_body = sgx_https::Client::new()
        .get("https://postman-echo.com/get")
        .header("x-h1", "v1")
        .query(&[("foo", "bar"), ("foo", "rab")])
        .query(&[("baz", "")])
        .send()
        .unwrap()
        .text()
        .unwrap();
    println!("{}", response_body);
}

About


Languages

Language:Rust 100.0%