Skip to content

Commit f785396

Browse files
authored
Update HTTP/2 handling for session uploads (#233)
* Remove HTTP 1.1 downgrade for session uploads * Handle HTTP/2 0 (zero) response code for successful session data upload * Add debugging for actual server response, not curl interpreted response when using --debug-https
1 parent df7ff4f commit f785396

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/onedrive.d

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,7 @@ final class OneDriveApi
251251
}
252252
http.method = HTTP.Method.put;
253253
http.url = uploadUrl;
254-
255-
// Specify which HTTP version to use for session uploads
256-
// Curl 7.62.0 defaults to HTTP/2, we need to use HTTP/1.1
257-
http.handle.set(CurlOption.http_version,2);
258-
254+
259255
import std.conv;
260256
string contentRange = "bytes " ~ to!string(offset) ~ "-" ~ to!string(offset + offsetSize - 1) ~ "/" ~ to!string(fileSize);
261257
http.addRequestHeader("Content-Range", contentRange);
@@ -334,7 +330,7 @@ final class OneDriveApi
334330
auto response = perform();
335331
checkHttpCode(response);
336332
if (.debugResponse){
337-
log.vlog("OneDrive Response: ", response);
333+
log.vlog("OneDrive API Response: ", response);
338334
}
339335
return response;
340336
}
@@ -483,9 +479,15 @@ final class OneDriveApi
483479
char[] content;
484480
http.onReceive = (ubyte[] data) {
485481
content ~= data;
482+
// HTTP Server Response Code Debugging
483+
if (.debugResponse){
484+
log.vlog("OneDrive HTTP Server Response: ", http.statusLine.code);
485+
}
486+
486487
return data.length;
487488
};
488489

490+
489491
try {
490492
http.perform();
491493
} catch (CurlException e) {
@@ -511,7 +513,7 @@ final class OneDriveApi
511513
// https://developer.overdrive.com/docs/reference-guide
512514

513515
/*
514-
Error response handling
516+
HTTP/1.1 Response handling
515517
516518
Errors in the OneDrive API are returned using standard HTTP status codes, as well as a JSON error response object. The following HTTP status codes should be expected.
517519
@@ -544,10 +546,16 @@ final class OneDriveApi
544546
507 Insufficient Storage The maximum storage quota has been reached.
545547
509 Bandwidth Limit Exceeded Your app has been throttled for exceeding the maximum bandwidth cap. Your app can retry the request again after more time has elapsed.
546548
549+
HTTP/2 Response handling
550+
551+
0 OK
552+
547553
*/
548554

549555
switch(http.statusLine.code)
550556
{
557+
case 0:
558+
break;
551559
// 200 - OK
552560
case 200:
553561
// No Log ..

0 commit comments

Comments
 (0)