Commit 0791c71
refactor: consolidate duplicated request-handling logic into BaseDAVClient
Extract four shared helpers from the identical/near-identical code that
existed in both _sync_request and _async_request:
_prepare_request(url, method, body, headers)
→ (url_obj, combined_headers)
Combines client headers with per-request headers, strips Content-Type
for empty bodies, objectifies the URL, and emits the debug log line.
Removes 7 identical lines from each client.
_should_negotiate_auth(status_code, headers) -> bool
The 401 + WWW-Authenticate + no-existing-auth + credentials-present
condition, previously copy-pasted into both clients.
_build_auth_from_401(www_authenticate)
Calls extract_auth_types / build_auth_object and raises
NotImplementedError if the server offers no supported method.
Removes the identical 6-line block from each client.
_raise_authorization_error(url_str, reason_source) -> NoReturn
Extracts reason from reason_source.reason (AttributeError → "None
given") and raises AuthorizationError. Removes the identical
try/except block from each client.
Side-effects:
- to_normal_str import removed from both davclient.py and async_davclient.py
(now only imported in base_client.py where it is used)
- No behaviour changes; all 123 unit tests pass
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 572d07b commit 0791c71
3 files changed
Lines changed: 79 additions & 76 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
| 378 | + | |
391 | 379 | | |
392 | 380 | | |
393 | 381 | | |
| |||
479 | 467 | | |
480 | 468 | | |
481 | 469 | | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
501 | 473 | | |
502 | 474 | | |
503 | 475 | | |
| |||
530 | 502 | | |
531 | 503 | | |
532 | 504 | | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
| 505 | + | |
538 | 506 | | |
539 | 507 | | |
540 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | | - | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
| 23 | + | |
| 24 | + | |
19 | 25 | | |
20 | 26 | | |
21 | 27 | | |
| |||
127 | 133 | | |
128 | 134 | | |
129 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
130 | 196 | | |
131 | 197 | | |
132 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
979 | 979 | | |
980 | 980 | | |
981 | 981 | | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
990 | | - | |
| 982 | + | |
991 | 983 | | |
992 | 984 | | |
993 | 985 | | |
994 | 986 | | |
995 | 987 | | |
996 | 988 | | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | 989 | | |
1002 | 990 | | |
1003 | 991 | | |
| |||
1015 | 1003 | | |
1016 | 1004 | | |
1017 | 1005 | | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
1035 | | - | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
1036 | 1009 | | |
1037 | 1010 | | |
1038 | 1011 | | |
1039 | 1012 | | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | | - | |
| 1013 | + | |
1045 | 1014 | | |
1046 | 1015 | | |
1047 | 1016 | | |
| |||
0 commit comments