我想使用退避重试机制 发送http请求列表。
有什么方法可以标记(带标记)仅在重试后成功的请求吗?
我看到的解决方案很少:
1)https://github.com/rholder/guava-retrying
2)https://developers.google.com/api-client-library/java/google-http-java-client/backoff
但是没有办法整合这个标记。这些库中的任何其他库或想法?
我试图覆盖此方法,但无法返回该指示标志
require("includes/connection.php");
$page ='/login.php';
require("includes/logs/log.php");
require("includes/update_session.php");
if(!empty($_SESSION['user'])) {
echo '<script>window.location = "/index.php";</script>';
die("Redirecting to index.php");
}
$submitted_username = '';
if(!empty($_POST)) {
$query = "SELECT id,username,password,salt,email
FROM users
WHERE username = :username";
$query_params = array(':username' => $_POST['username']);
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex) {
die("Failed to run query: " . $ex->getMessage());
}
$login_ok = false;
$row = $stmt->fetch();
if($row) {
$query = "INSERT INTO CSD_LOGIN_ATTEMPTS (id) VALUES (:id)";
$query_params = array(':id' => $row["id"]);
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex) {
die("Failed to run query: " . $ex->getMessage());
}
$check_password = hash('sha256', $_POST['password'] . $row['salt']);
for($round = 0; $round < 65536; $round++) {
$check_password = hash('sha256', $check_password . $row['salt']);
}
if($check_password === $row['password']) {
$login_ok = true;
}
}
if($login_ok) {
unset($row['salt']);
unset($row['password']);
$_SESSION['user'] = $row;
session_write_close();
echo '<script>window.location="/index.php";</script>';
die("Redirecting to: index.php");
} else {
print("Login Failed.");
$submitted_username = htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8');
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
require("includes/scripts.php");
?>
</head>
<body><center>
<div id="pagewidth">
<?php
require("includes/header.php");
?>
<div id="content">
<section class="row">
<h1>Login</h1>
<form action="login.php" method="post" class='form'>
Username:<br />
<input style='text-align: center' type="text" name="username" value="<?php echo $submitted_username; ?>" />
<br /><br />
Password:<br />
<input style='text-align: center' type="password" name="password" value="" />
<br /><br />
<button type="submit" value="Login" class='btnSmall grey'>Login</button>
</form><br>
<a href="register.php">Register</a>
</section>
<section class="row grey">
</section>
</div>
<?php
include("includes/footer.php");
?>
</div>
</center></body>
</html>