Change timeout to 5s, then assume offline
This commit is contained in:
		@@ -16,9 +16,13 @@ func routes(_ app: Application) throws {
 | 
			
		||||
 | 
			
		||||
    app.get("status", ":url") { req -> [String: String] in
 | 
			
		||||
        let url = URL(string: "http://\(req.parameters.get("url")!)")
 | 
			
		||||
        let config = URLSessionConfiguration.default
 | 
			
		||||
        config.timeoutIntervalForRequest = 5
 | 
			
		||||
        config.timeoutIntervalForResource = 5
 | 
			
		||||
        var statusDict: [String:String] = [:]
 | 
			
		||||
        var headReq = URLRequest(url: url!)
 | 
			
		||||
        headReq.httpMethod = "HEAD"
 | 
			
		||||
        headReq.timeoutInterval = 5
 | 
			
		||||
        let semaphore = DispatchSemaphore(value: 0)
 | 
			
		||||
        URLSession.shared.dataTask(with: headReq, completionHandler:  { (_, response, error) in
 | 
			
		||||
            if let httpURLResponse = response as? HTTPURLResponse {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user