Commit 40a4c53a authored by Dominik Hebeler's avatar Dominik Hebeler

Merge branch '1024-optimize-request-fetcher' into 'development'

Resolve "Optimize Request fetcher"

Closes #1024

See merge request !1706
parents 11f21266 44e48c90
......@@ -44,6 +44,9 @@ class AdminSpamController extends Controller
public function jsonQueries()
{
$queries = $this->getQueries();
# JSON encoding will fail if invalid UTF-8 Characters are in this string
# mb_convert_encoding will remove thise invalid characters for us
$queries = mb_convert_encoding($queries, "UTF-8", "UTF-8");
return response()->json($queries);
}
......@@ -77,8 +80,10 @@ class AdminSpamController extends Controller
];
}
# JSON encoding will fail if invalid UTF-8 Characters are in this string
# mb_convert_encoding will remove thise invalid characters for us
$resultData = mb_convert_encoding($resultData, "UTF-8", "UTF-8");
return response()->json($resultData);
}
private function getQueries()
......
......@@ -12,7 +12,6 @@ use View;
class MetaGerSearch extends Controller
{
public function search(Request $request, MetaGer $metager, $timing = false)
{
if ($request->filled("chrome-plugin")) {
......@@ -156,7 +155,7 @@ class MetaGerSearch extends Controller
// This might speed up page view time for users with slow network
$responseArray = str_split($resultpage->render(), 1024);
foreach ($responseArray as $responsePart) {
echo ($responsePart);
echo($responsePart);
flush();
}
$requestTime = microtime(true) - $time;
......@@ -182,7 +181,6 @@ class MetaGerSearch extends Controller
if ($request->filled('loadMore') && $request->filled('script') && $request->input('script') === "yes") {
return $this->loadMoreJS($request);
}
}
private function loadMoreJS(Request $request)
......@@ -296,6 +294,10 @@ class MetaGerSearch extends Controller
],
"engines" => $metager->getEngines(),
], 1 * 60);
# JSON encoding will fail if invalid UTF-8 Characters are in this string
# mb_convert_encoding will remove thise invalid characters for us
$result = mb_convert_encoding($result, "UTF-8", "UTF-8");
return response()->json($result);
}
......
......@@ -5,6 +5,7 @@ namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Redis;
use Jenssegers\Agent\Agent;
use Cache;
class BrowserVerification
{
......@@ -59,12 +60,12 @@ class BrowserVerification
$key = md5($request->ip() . microtime(true));
echo (view('layouts.resultpage.verificationHeader')->with('key', $key)->render());
echo(view('layouts.resultpage.verificationHeader')->with('key', $key)->render());
flush();
$answer = Redis::connection("cache")->blpop($key, 2);
if ($answer !== null) {
echo (view('layouts.resultpage.resources')->render());
echo(view('layouts.resultpage.resources')->render());
flush();
$request->request->add(["headerPrinted" => true, "jskey" => $key]);
return $next($request);
......@@ -74,9 +75,8 @@ class BrowserVerification
$params["mgv"] = $key;
$url = route("resultpage", $params);
echo (view('layouts.resultpage.unverifiedResultPage')
echo(view('layouts.resultpage.unverifiedResultPage')
->with('url', $url)
->render());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment