-
Notifications
You must be signed in to change notification settings - Fork 1
Kate/resources #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d460291
17bbedd
5bfbf0b
b00e656
851489b
7282155
5e87822
b1dc2e5
5bbd2e9
8dc0683
d238989
c7cfeb7
fcb42a3
81c7501
c15c677
2a7fcec
07f5da8
bbf55c1
642c9f0
d19e302
141250f
5eb6330
5968bc4
fa691df
e98800d
4ab9db8
b470576
09be440
bc9d22d
b1873cc
1e298fb
d843315
8a5ee40
3d12f1f
58afd05
54c4249
67c884b
169a677
1549f38
fe852de
0c71f65
a27b61f
338584f
6b3fd8c
d4805aa
c0b393d
a8d321f
13b3fc5
5050b1f
2cfa4c8
ef6ef82
d5d416e
0eaa13a
35b9624
7fec620
391a3a7
a5b3436
d3b0291
549de07
09a5e69
efa9035
af54120
f8d904f
60e8beb
95a5739
57d2ee0
440c768
0552a30
6d50e0f
47712f1
2ace6d4
4bfc9fe
bbf2ef8
a497e50
1298b81
ebc3848
4914bcf
a2bd9a5
6b2f0a4
7496b84
1457e7d
fd64e7a
f98c714
87a8857
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| from enum import Enum | ||
| import gzip | ||
| import requests | ||
| from urllib.parse import urlparse | ||
| from urllib3.response import HTTPResponse | ||
|
|
||
| STRING_SEPARATOR = " | " | ||
|
|
||
|
|
@@ -44,3 +48,29 @@ def bbox_from_list(raw_bbox_list: list): | |
| ) | ||
|
|
||
| return InlineList(list_bbox_val) | ||
|
|
||
|
|
||
| def is_url_responsive(url: str, detect_exceptions_in_successful_response=False) -> bool: | ||
|
|
||
| parsed_url = urlparse(url) | ||
| if not all([parsed_url.scheme, parsed_url.netloc]): | ||
| return False | ||
|
|
||
| try: | ||
| if detect_exceptions_in_successful_response: | ||
| # Detect OGC ExceptionReport (invalid request) | ||
| response = requests.get(url, allow_redirects=True, timeout=5) | ||
| if response.status_code != 200: | ||
| return False | ||
| else: | ||
| text = response.text | ||
| if "ExceptionReport" in text or "ExceptionText" in text: | ||
doublebyte1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return False | ||
| return True | ||
|
|
||
| else: # lighter request (if content is not needed) | ||
|
||
| response = requests.head(url, allow_redirects=True, timeout=5) | ||
| return response.status_code == 200 | ||
|
|
||
| except requests.RequestException: | ||
| return False | ||
Uh oh!
There was an error while loading. Please reload this page.