feat: enhance user-agent identification and implement backoff strategy for university source requests
- Added PSU_CONTACT environment variable to docker-compose for owner contact in User-Agent. - Updated source.js to include user-agent construction with service version and contact information. - Implemented exponential backoff strategy for failed requests to the university, with retry logic based on HTTP response status. - Modified status.js to display backoff information in the status response. - Adjusted watch.js to reduce request frequency during university downtime. - Enhanced test coverage with new backoff.test.js to validate backoff behavior and user-agent format.
This commit is contained in:
@@ -50,10 +50,11 @@ const listing = (folder) => {
|
||||
* stand-in's documents during a test, and `stop()`.
|
||||
*/
|
||||
export async function startApi(env = {}) {
|
||||
const stats = { requests: 0, connections: 0, listings: 0 };
|
||||
const stats = { requests: 0, connections: 0, listings: 0, userAgent: null };
|
||||
let down = false;
|
||||
const source = createServer((req, res) => {
|
||||
stats.requests++;
|
||||
stats.userAgent = req.headers["user-agent"] || null;
|
||||
if (req.method === "PROPFIND") stats.listings++;
|
||||
if (down) return res.writeHead(503).end();
|
||||
const path = decodeURIComponent(req.url);
|
||||
|
||||
Reference in New Issue
Block a user