-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTPClient : Support for full URL argument instead of host & port #812
Comments
Hey! Could I pick up this issue? |
@lalitb Would you rather have me allow for HttpClient::CreateSession to have the template have multiple parameters, one for host/port and one for a full url? Or would you rather have me change the current implementation to simply fix https and work for full url |
I’d like to work on this issue. Can you please assign this to me? @alolita |
Thanks @ohamuy - assigned to you now. We can use function overloading to support both unless you see benefit with templates? |
Yea @lalitb I could definitely do function overloading. Also how do we know whether the user wants http or https appended if they only provide the host and port? Also for testing would I use Bazel or is there some other way to test my code? |
default should be always |
Hey @lalitb @reyang I wrote this block of code overloading the Session to allow for url input. This utilizes the urlparser in the common folder. What would you like me to return if it doesn't successfully parse? Nullptr? Also this code compiles successfully using Bazel Are there any additional features besides this url addition that are needed (like in the constructor or implementation)? Also how should I validate that this overload function works properly? Should I create and run an example in the examples folder or is the http Bazel example sufficient?
|
@ohamuy - Your approach looks good. We can return the Session object with an empty/non-existent host, and default port(80). And let the actual connection failure get caught at ResponseHandler level: std::shared_ptr<http_client::Session> CreateSession(nostd::string_view url) noexcept override
{
auto parsedUrl = common::UrlParser(std::string(url));
if (!parsedUrl.success_) {
//TBD - Log error once error handler is supported
return std::make_shared<Session>(*this, "empty-host", 80);
}
auto session = std::make_shared<Session>(*this, parsedUrl.host_, parsedUrl.port_);
auto session_id = ++next_session_id_;
session->SetId(session_id);
sessions_.insert({session_id, session});
return session;
} While using , auto session = httpClient.createSession("localhost", 8000);
auto request = session->CreateRequest();
request->AddHeader(..);
SimpleResponseHandler res_handler;
session->SendRequest(res_handler);
|
@lalitb Ok great, I'll add these changes and get a PR ready (will have to get it reviewed first within Amazon!) |
We can close this issue now, correct? @lalitb |
As discussed here:
HttpClientSync::Get(url)
andHttpClientSync::Post(url)
methods.TODO
from here oncehttps
works/fixed:opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h
Line 123 in ac0e617
The text was updated successfully, but these errors were encountered: