use std::{borrow::Cow, collections::HashMap};
use candid::CandidType;
use serde::Deserialize;
pub use ic_cdk::api::management_canister::http_request::{HttpResponse, TransformArgs};
pub fn transform(response: TransformArgs) -> HttpResponse {
let mut t = response.response;
t.headers = vec![];
t
}
pub const MAX_RESPONSE_LENGTH: usize = 3145728 - 1024 * 64;
#[derive(CandidType, Deserialize)]
pub struct CustomHttpRequest {
pub method: String,
pub url: String,
pub headers: HashMap<String, String>,
pub body: Vec<u8>,
}
#[derive(Clone, Debug, CandidType, Deserialize)]
pub struct StreamingCallbackToken {
pub path: String, pub params: String, pub headers: HashMap<String, String>, pub start: u64, pub end: u64, }
#[derive(Clone, Debug, CandidType, Deserialize)]
pub struct StreamingCallbackHttpResponse {
pub body: Vec<u8>, pub token: Option<StreamingCallbackToken>, }
candid::define_function!(pub HttpRequestStreamingCallback : (StreamingCallbackToken) -> (StreamingCallbackHttpResponse) query);
#[derive(Clone, Debug, CandidType, Deserialize)]
pub enum StreamingStrategy {
Callback {
callback: HttpRequestStreamingCallback, token: StreamingCallbackToken,
},
}
#[derive(CandidType)]
pub struct CustomHttpResponse<'a> {
pub status_code: u16,
pub headers: HashMap<&'a str, Cow<'a, str>>,
pub body: Cow<'a, [u8]>,
pub streaming_strategy: Option<StreamingStrategy>, }