99
1010import arrow
1111
12- ASGIHeaders = Iterable [tuple [bytes , bytes ]]
13-
12+ # Common ---
1413
15- CLIENT_USER_AGENT_RE_FIREFOX = r"^Mozilla/5.0.+Gecko/.+Firefox/"
16- CLIENT_USER_AGENT_RE_SAFARI = r"^Mozilla/5.0.+Version/.+Safari/"
17- CLIENT_USER_AGENT_RE_CHROME = r"^Mozilla/5.0.+Chrome/.+Safari/"
18- CLIENT_USER_AGENT_RE_MACOS_FINDER = r"^WebDAVFS/"
19- CLIENT_USER_AGENT_RE_WINDOWS_EXPLORER = r"^Microsoft-WebDAV-MiniRedir/"
14+ ASGIHeaders = Iterable [tuple [bytes , bytes ]]
2015
2116
2217class DAVUpperEnumAbc (Enum ):
@@ -28,6 +23,8 @@ def _missing_(cls, value: str): # type: ignore
2823 return cls [value .upper ()]
2924
3025
26+ # WebDAV protocol ---
27+
3128DAV_METHODS = {
3229 # rfc4918:9.1
3330 "PROPFIND" ,
@@ -283,6 +280,74 @@ def __repr__(self):
283280 return f"DAVLockInfo({ s } )"
284281
285282
283+ DAV_PROPERTY_BASIC_KEYS = {
284+ # Identify
285+ "displayname" ,
286+ "getetag" ,
287+ # Date Time
288+ "creationdate" ,
289+ "getlastmodified" ,
290+ # File Properties
291+ "getcontenttype" ,
292+ "getcontentlength" ,
293+ # 'getcontentlanguage',
294+ # is dir
295+ "resourcetype" ,
296+ "encoding" ,
297+ # 'supportedlock', 'lockdiscovery'
298+ # 'executable'
299+ }
300+
301+ DAVPropertyIdentity = NewType (
302+ # (namespace, key)
303+ "DAVPropertyIdentity" ,
304+ tuple [str , str ],
305+ )
306+ DAVPropertyPatches = NewType (
307+ "DAVPropertyPatches" ,
308+ list [
309+ # (DAVPropertyIdentity(sn_key), value, set<True>/remove<False>)
310+ tuple [DAVPropertyIdentity , str , bool ]
311+ ],
312+ )
313+
314+ # HTTP protocol ---
315+
316+ RESPONSE_DATA_BLOCK_SIZE = 64 * 1024
317+
318+
319+ class DAVAcceptEncoding :
320+ # https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Encoding
321+ # https://caniuse.com/?search=gzip
322+ # identity
323+ gzip : bool = False
324+ br : bool = False
325+
326+ def __repr__ (self ):
327+ return f"gzip:{ self .gzip } , br:{ self .br } "
328+
329+
330+ DEFAULT_COMPRESSION_CONTENT_MINIMUM_LENGTH = 1000 # bytes
331+ DEFAULT_COMPRESSION_CONTENT_TYPE_RULE = r"^application/xml$|^text/"
332+
333+
334+ class DAVCompressLevel (Enum ):
335+ """
336+ http://mattmahoney.net/dc/text.html
337+ https://quixdb.github.io/squash-benchmark/
338+ https://sites.google.com/site/powturbo/home/benchmark
339+ """
340+
341+ FAST = "fast"
342+ RECOMMEND = "recommend"
343+ BEST = "best"
344+
345+
346+ # Authentication ---
347+
348+ DEFAULT_HTTP_BASIC_AUTH_CACHE_TIMEOUT = 60 * 60 # 1 hour
349+
350+
286351@dataclass
287352class DAVUser :
288353 username : str
@@ -333,36 +398,13 @@ def __str__(self):
333398 )
334399
335400
336- DAV_PROPERTY_BASIC_KEYS = {
337- # Identify
338- "displayname" ,
339- "getetag" ,
340- # Date Time
341- "creationdate" ,
342- "getlastmodified" ,
343- # File Properties
344- "getcontenttype" ,
345- "getcontentlength" ,
346- # 'getcontentlanguage',
347- # is dir
348- "resourcetype" ,
349- "encoding" ,
350- # 'supportedlock', 'lockdiscovery'
351- # 'executable'
352- }
401+ # Extra ---
353402
354- DAVPropertyIdentity = NewType (
355- # (namespace, key)
356- "DAVPropertyIdentity" ,
357- tuple [str , str ],
358- )
359- DAVPropertyPatches = NewType (
360- "DAVPropertyPatches" ,
361- list [
362- # (DAVPropertyIdentity(sn_key), value, set<True>/remove<False>)
363- tuple [DAVPropertyIdentity , str , bool ]
364- ],
365- )
403+ CLIENT_USER_AGENT_RE_FIREFOX = r"^Mozilla/5.0.+Gecko/.+Firefox/"
404+ CLIENT_USER_AGENT_RE_SAFARI = r"^Mozilla/5.0.+Version/.+Safari/"
405+ CLIENT_USER_AGENT_RE_CHROME = r"^Mozilla/5.0.+Chrome/.+Safari/"
406+ CLIENT_USER_AGENT_RE_MACOS_FINDER = r"^WebDAVFS/"
407+ CLIENT_USER_AGENT_RE_WINDOWS_EXPLORER = r"^Microsoft-WebDAV-MiniRedir/"
366408
367409DEFAULT_FILENAME_CONTENT_TYPE_MAPPING = {
368410 "README" : "text/plain" ,
@@ -410,34 +452,8 @@ def __str__(self):
410452 CLIENT_USER_AGENT_RE_WINDOWS_EXPLORER : HIDE_FILE_IN_DIR_RULE_MACOS ,
411453}
412454
413- RESPONSE_DATA_BLOCK_SIZE = 64 * 1024
414-
415455
416- class DAVAcceptEncoding :
417- # https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Encoding
418- # https://caniuse.com/?search=gzip
419- # identity
420- gzip : bool = False
421- br : bool = False
422-
423- def __repr__ (self ):
424- return f"gzip:{ self .gzip } , br:{ self .br } "
425-
426-
427- DEFAULT_COMPRESSION_CONTENT_MINIMUM_LENGTH = 1000 # bytes
428- DEFAULT_COMPRESSION_CONTENT_TYPE_RULE = r"^application/xml$|^text/"
429-
430-
431- class DAVCompressLevel (Enum ):
432- """
433- http://mattmahoney.net/dc/text.html
434- https://quixdb.github.io/squash-benchmark/
435- https://sites.google.com/site/powturbo/home/benchmark
436- """
437-
438- FAST = "fast"
439- RECOMMEND = "recommend"
440- BEST = "best"
456+ # Development ---
441457
442458
443459class DevMode (Enum ):
0 commit comments