Skip to content

Commit

Permalink
feat: support http3 (quiche)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ossianaa committed Oct 2, 2024
1 parent bac31c7 commit 1d0868f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
"type": "git",
"url": "git@github.com/Ossianaa/node-libcurl.git"
},
"artifacts-version": "v1.0.8"
"artifacts-version": "v1.0.9"
}
4 changes: 3 additions & 1 deletion src/libcurl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ BaoLibCurl.globalInit();
export enum LibCurlHttpVersionInfo {
http1_1,
http2,
http3,
http3_only,
}

//Domain Secure Path CORS TimeStamp Name Value
Expand Down Expand Up @@ -275,7 +277,7 @@ export class LibCurl {
}

public setRequestHeader(key: string, value: string): void {
this.m_requestHeaders_.set(key, value);
this.m_requestHeaders_.set(key.trimStart(), value);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/libcurl/bao_curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ void BaoCurl::setHttpVersion(BaoCurl::HttpVersion version)
case BaoCurl::HttpVersion::http2:
temp = CURL_HTTP_VERSION_2;
break;
case BaoCurl::HttpVersion::http3:
temp = CURL_HTTP_VERSION_3;
case BaoCurl::HttpVersion::http3_only:
temp = CURL_HTTP_VERSION_3ONLY;
break;
default:
printf("error httpVersion!\n");
return;
Expand Down
8 changes: 8 additions & 0 deletions src/libcurl/bao_curl_node_addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,14 @@ Napi::Value BaoLibCurlWarp::setHttpVersion(const Napi::CallbackInfo &info)
{
this->m_curl.setHttpVersion(BaoCurl::HttpVersion::http2);
}
else if (ver == 2)
{
this->m_curl.setHttpVersion(BaoCurl::HttpVersion::http3);
}
else if (ver == 3)
{
this->m_curl.setHttpVersion(BaoCurl::HttpVersion::http3_only);
}
else
{
REQUEST_TLS_METHOD_THROW(env, "BaoCurl", "setHttpVersion", "Version Not Support.")
Expand Down
2 changes: 2 additions & 0 deletions src/libcurl/include/bao_curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class BaoCurl
{
http1_1,
http2,
http3,
http3_only,
};
void setHttpVersion(HttpVersion);
void enableConnectReuse(bool);
Expand Down

0 comments on commit 1d0868f

Please sign in to comment.