Issue 19385 - Question: How to set curl options for HTTP from inside dmd?
Summary: Question: How to set curl options for HTTP from inside dmd?
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-09 23:07 UTC by Alex Braunegg
Modified: 2024-12-01 16:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Alex Braunegg 2018-11-09 23:07:57 UTC
Hi,

In Curl 7.62.0, this now defaults to using HTTP 2.0 for connections where h2 is available, when build with h2 support. 

Is there a way to set the libcurl options to force http 1.1 for all connections rather than using 'no flag' which lets libcurl choose the connection mechanism?

I have tried the following:

import std.net.curl;
http = HTTP();
http.handle.set(CurlOption.http_version,"v1_1");

However this generates the following error:

std.net.curl.CurlException@std/net/curl.d(4340): Unsupported protocol on handle 555E47E726A0

Can anyone advise how to set the curl options so that I can tell the library to only use http 1.1?

The issue I am trying to solve is - when DMD is using HTTP2 for file downloads, 'something' is happening when the file download is being completed which is causing an error - as the file 'disappears'. When downgrading the curl library to 7.61.0 (which does not enable http2 by default) there is no issue.

References: 
https://dlang.org/library/etc/c/curl/curl_http_version.html
https://github.com/abraunegg/onedrive/issues/220
https://github.com/curl/curl/issues/3253
Comment 1 anonymous4 2018-11-12 13:14:11 UTC
See issue 19367 - until 8 november phobos didn't support http2, you're getting http status 0 and throw an exception for it, you also have a scope guard that deletes the file if exception is thrown, that exception is later caught and ignored, that's why you don't see anything happening. It's a good idea to log exception in its constructor - as soon as possible - this way you have little chance to ignore it, it's a life saver in remote debugging.
Comment 2 dlangBugzillaToGithub 2024-12-01 16:34:30 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10359

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB