feat: update container
This commit is contained in:
@@ -45,8 +45,8 @@ pub fn do_fetch(params: &str) -> FnResult {
|
||||
m => return FnResult::fail(format!("Unsupported method: {}", m)),
|
||||
};
|
||||
let mut request_builder = client.request(request_method.clone(), &fetch_params.url);
|
||||
let mut has_user_agent = false;
|
||||
if let Some(options) = &fetch_params.options {
|
||||
let mut has_user_agent = false;
|
||||
if let Some(headers) = &options.headers {
|
||||
for (k, v) in headers {
|
||||
let k = k.to_lowercase();
|
||||
@@ -56,10 +56,11 @@ pub fn do_fetch(params: &str) -> FnResult {
|
||||
request_builder = request_builder.header(k, v.to_string());
|
||||
}
|
||||
}
|
||||
if !has_user_agent {
|
||||
request_builder = request_builder.header("User-Agent", "JavaScriptSandboxContainer/0.1");
|
||||
}
|
||||
|
||||
}
|
||||
if !has_user_agent {
|
||||
request_builder = request_builder.header("User-Agent", "JavaScriptSandboxContainer/0.1");
|
||||
}
|
||||
if let Some(options) = &fetch_params.options {
|
||||
if let Some(body) = &options.body {
|
||||
if Method::POST == request_method {
|
||||
let body = reqwest::blocking::Body::from(body.to_string());
|
||||
|
||||
@@ -38,10 +38,14 @@ fn main() -> Result<()> {
|
||||
let a = exports.eval_javascript(&mut store, r##"
|
||||
function hi(name) { return "hi: " + name; }
|
||||
let a = [];
|
||||
a.push(fetch('https://hatter.ink/util/print_request.action'));
|
||||
a.push(fetch('https://hatter.ink/ip.action'));
|
||||
a.push(fetch('https://hatter.ink/util/print_request.action', {
|
||||
headers: {
|
||||
'Test-Header': 'this is a test header'
|
||||
}
|
||||
}));
|
||||
// a.push(fetch('https://hatter.ink/ip.action'));
|
||||
a.push(fetch('https://hatter.ink/ip/ip.jsonp'));
|
||||
a.push(fetch('https://hatter.ink/ip2.action'));
|
||||
// a.push(fetch('https://hatter.ink/ip2.action'));
|
||||
a.push({
|
||||
userId: 'id001',
|
||||
name: 'Test',
|
||||
|
||||
Reference in New Issue
Block a user