LoginSignup
1
2

More than 5 years have passed since last update.

D言語でBasic認証

Last updated at Posted at 2016-10-25

std.net.curlを使えば簡単にできた。探すのにすこし時間がかかったのでサンプル的なものを書く。

import std.stdio : writeln;
import std.net.curl : HTTP,get;
void main()
{
    auto url = "URL";
    auto user = "USER";
    auto pass = "PASS";

    auto http = HTTP();
    http.authenticationMethod = HTTP.AuthMethod.basic;
    http.setAuthentication(user,pass);

    auto content = get(url,http);
    writeln(content);
}

HTTP.AuthMethodはetc.c.curl.CurlAuthのエイリアス。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2