<?php
namespace Requests;
public static function __init(
array $arr, array $postFile, array $putFile, array $postFields,
array $options, array $headers, array $put_data, array $query_data,
array $body, array $content_type, array $method,
array $raw_post_data, array $ssl_options, $clear_history = false
) : array{
try {
$pool_requests = [];
for($i = 0; $i < sizeof($arr); $i++){
array_push($pool_requests, new HttpRequest($arr[$i], HttpRequest::METH_HEAD));
$pool = new HttpRequestPool($pool_requests);
if($postFile[$i]){
for($i2 = 0; $i2 < sizeof($postFile[$i]); $i2++){
$pool->setPostFiles($postFile[$i][$i2]);
}
}
if($putFile[$i]){
for($i6 = 0; $i6 < sizeof($postFile[$i]); $i6++){
$pool->setPostFiles($postFile[$i][$i6]);
}
}
if($options[$i]){
$pool->setOptions($options[$i]);
}
if($postFields[$i]){
$pool->setPostFields($postFields[$i]);
}
if($headers[$i]){
$pool->setHeaders($headers[$i]);
}
if($put_data[$i]){
for($i3 = 0; $i3 < sizeof($put_data[$i]); $i3++){
$pool->setPutData($put_data[$i][$i3]);
}
}
if($query_data[$i]){
for($i4 = 0; $i4 < sizeof($query_data[$i]); $i4++){
$pool->setQueryData($query_data[$i][$i4]);
}
}
if($raw_post_data[$i]){
for($i5 = 0; $i5 < sizeof($row_post_data[$i]); $i5++){
$pool->setRawPostData($row_post_data[$i][$i5]);
}
}
if($ssl_options[$i]){
for($i7 = 0; $i7 < sizeof($ssl_options[$i]); $i7++){
$pool->setSslOptions($ssl_post_data[$i][$i7]);
}
}
if($body[$i]){
for($i9 = 0; $i9 < sizeof($body[$i]); $i9++){
$pool->setBody($body[$i][$i9]);
}
}
if($content_type[$i]){
$pool->setContentType($content_type[$i]);
}
if($method[$i]){
$pool->setMethod($content_type[$i]);
}
$pool->enableCookies();
$pool->send();
$clear_history ? $pool->clearHistory() : continue;
}
$retur_val = [];
for($i8 = 0; $i8 < sizeof($pool); $i8++) {
$return_val[$i8]['url'] = $pool->getUrl();
$return_val[$i8]['response_code'] = $pool->getResponseCode();
$return_val[$i8]['response_cookies'] = $pool->getResponseCookie();
$return_val[$i8]['response_status'] = $pool->getResponseStatus();
$return_val[$i8]['response_data'] = $pool->getResponseData();
$return_val[$i8]['response_header'] = $pool->getResponseHeader();
$return_val[$i8]['response_body'] = $pool->getResponseBody();
$return_val[$i8]['response_info'] = $pool->getResponseInfo();
$return_val[$i8]['response_ssl'] = $pool->getSslOptions();
$return_val[$i8]['response_put_file'] = $pool->getPutFile();
$return_val[$i8]['response_put_data'] = $pool->getPutData();
$return_val[$i8]['response_post_files'] = $pool->getPostFiles();
$return_val[$i8]['response_post_fields'] = $pool->getPostFields();
$return_val[$i8]['response_options'] = $pool->getOptions();
$return_val[$i8]['response_message'] = $pool->getMessage();
$return_val[$i8]['response_history'] = $pool->getHistory();
$return_val[$i8]['response_content_type'] = $pool->getContentType();
$return_val[$i8]['response_method'] = $pool->getMethod();
$return_val[$i8]['response_query'] = $pool->getQueryData();
}
header('Content-Type: application/json');
http_response_code($pool->getResponseCode());
return json_encode($return_val, JSON_PRETTY_PRINT);
} catch (HttpException $e) {
header('Content-Type: application/json');
http_response_code(400);
return json_encode(['code' => $e->getCode(), 'Message' => $e->getMessage()], JSON_PRETTY_PRINT);
} catch (Exception $ex) {
header('Content-Type: application/json');
http_response_code(400);
return json_encode(['code' => $ex->getCode(), 'Message' => $ex->getMessage()], JSON_PRETTY_PRINT);
}
}
}