Go to the documentation of this file.
28 #include "absl/container/inlined_vector.h"
29 #include "absl/functional/bind_front.h"
30 #include "absl/status/status.h"
31 #include "absl/strings/str_format.h"
75 if (g_get_override !=
nullptr) {
76 test_only_generate_response = [
request, uri, deadline, on_done,
81 g_get_override(
request, uri.authority().c_str(), uri.path().c_str(),
89 return MakeOrphanable<HttpRequest>(
91 pollent,
name.c_str(),
std::move(test_only_generate_response),
101 if (g_post_override !=
nullptr) {
102 test_only_generate_response = [
request, uri, deadline, on_done,
104 g_post_override(
request, uri.authority().c_str(), uri.path().c_str(),
113 return MakeOrphanable<HttpRequest>(
115 pollent,
name.c_str(),
std::move(test_only_generate_response),
125 if (g_put_override !=
nullptr) {
126 test_only_generate_response = [
request, uri, deadline, on_done,
128 g_put_override(
request, uri.authority().c_str(), uri.path().c_str(),
137 return MakeOrphanable<HttpRequest>(
139 pollent,
name.c_str(),
std::move(test_only_generate_response),
146 g_get_override =
get;
147 g_post_override =
post;
148 g_put_override = put;
153 g_test_only_on_handshake_done_intercept = intercept;
163 request_text_(request_text),
166 .channel_args_preconditioning()
167 .PreconditionChannelArgs(channel_args)
174 test_only_generate_response_(
std::
move(test_only_generate_response)) {
182 grpc_schedule_on_exec_ctx);
186 grpc_schedule_on_exec_ctx);
194 if (own_endpoint_ &&
ep_ !=
nullptr) {
223 if (dns_request_handle_.has_value() &&
226 "cancelled during DNS resolution"));
229 if (handshake_mgr_ !=
nullptr) {
232 "HTTP request cancelled during handshake"));
234 if (own_endpoint_ &&
ep_ !=
nullptr) {
253 addr_text.ok() ? addr_text.value() : addr_text.status().ToString()));
257 for (
size_t i = 0;
i < incoming_.count;
i++) {
270 "HTTP1 request cancelled during read", &overall_error_, 1));
273 }
else if (!have_read_byte_) {
302 if (g_test_only_on_handshake_done_intercept !=
nullptr) {
305 g_test_only_on_handshake_done_intercept(
req.get());
308 req->own_endpoint_ =
true;
310 req->handshake_mgr_.reset();
319 req->handshake_mgr_.reset();
320 if (
req->cancelled_) {
322 "HTTP request cancelled during handshake"));
334 &new_args_from_connector);
337 "failed to create security connector", &overall_error_, 1));
343 "Failed to extract URI from address", &overall_error_, 1));
350 const_cast<char*
>(address.
value().c_str())),
353 new_args_from_connector !=
nullptr ? new_args_from_connector
355 args_to_add.
data(), args_to_add.
size());
358 handshake_mgr_ = MakeRefCounted<HandshakeManager>();
364 own_endpoint_ =
false;
365 handshake_mgr_->DoHandshake(ep, new_args,
deadline_,
378 "HTTP request was cancelled", &overall_error_, 1));
383 "Failed HTTP requests to all targets", &overall_error_, 1));
391 absl::StatusOr<std::vector<grpc_resolved_address>> addresses_or) {
394 dns_request_handle_.reset();
397 "cancelled during DNS resolution"));
400 if (!addresses_or.ok()) {
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler)
const Timestamp deadline_
static void ContinueOnReadAfterScheduleOnExecCtx(void *user_data, grpc_error_handle error)
absl::string_view get(const Cont &c)
void OnReadInternal(grpc_error_handle error) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
const grpc_slice & grpc_slice_ref_internal(const grpc_slice &slice)
void NextAddress(grpc_error_handle error) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
grpc_closure continue_done_write_after_schedule_on_exec_ctx_
grpc_error_handle grpc_http_parser_eof(grpc_http_parser *parser)
constexpr ABSL_NAMESPACE_BEGIN functional_internal::bind_front_t< F, BoundArgs... > bind_front(F &&func, BoundArgs &&... args)
static void post(QUEUE *q, enum uv__work_kind kind)
void reset(T *value=nullptr)
grpc_pollset_set * grpc_pollset_set_create()
GPRAPI void gpr_free(void *ptr)
static void ContinueDoneWriteAfterScheduleOnExecCtx(void *arg, grpc_error_handle error)
absl::StatusOr< HierarchicalAddressMap > addresses_
ResourceQuotaRefPtr resource_quota_
void DoHandshake(const grpc_resolved_address *addr) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
#define GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(desc, errs, count)
grpc_closure continue_on_read_after_schedule_on_exec_ctx_
grpc_arg grpc_channel_arg_string_create(char *name, char *value)
static OrphanablePtr< HttpRequest > Post(URI uri, const grpc_channel_args *args, grpc_polling_entity *pollent, const grpc_http_request *request, Timestamp deadline, grpc_closure *on_done, grpc_http_response *response, RefCountedPtr< grpc_channel_credentials > channel_creds) GRPC_MUST_USE_RESULT
grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc)
int(* grpc_httpcli_post_override)(const grpc_http_request *request, const char *host, const char *path, const char *body_bytes, size_t body_size, grpc_core::Timestamp deadline, grpc_closure *on_complete, grpc_http_response *response)
grpc_error_handle grpc_error_set_str(grpc_error_handle src, grpc_error_strs which, absl::string_view str)
const std::string & path() const
void grpc_iomgr_unregister_object(grpc_iomgr_object *obj)
@ GRPC_ERROR_STR_TARGET_ADDRESS
peer that we were trying to communicate when this error occurred
static GraphId Get(const IdMap &id, int num)
static void SetOverride(grpc_httpcli_get_override get, grpc_httpcli_post_override post, grpc_httpcli_put_override put)
void AppendError(grpc_error_handle error) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
const absl::optional< std::function< void()> > test_only_generate_response_
static void DoneWrite(void *arg, grpc_error_handle error)
grpc_error_handle grpc_error_add_child(grpc_error_handle src, grpc_error_handle child)
void OnResolved(absl::StatusOr< std::vector< grpc_resolved_address >> addresses_or)
RefCountedPtr< grpc_channel_credentials > channel_creds_
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
std::shared_ptr< ChannelCredentials > channel_creds_
static const CoreConfiguration & Get()
constexpr bool has_value() const noexcept
HttpRequest(URI uri, const grpc_slice &request_text, grpc_http_response *response, Timestamp deadline, const grpc_channel_args *channel_args, grpc_closure *on_done, grpc_polling_entity *pollent, const char *name, absl::optional< std::function< void()>> test_only_generate_response, RefCountedPtr< grpc_channel_credentials > channel_creds)
const std::string & authority() const
int(* grpc_httpcli_put_override)(const grpc_http_request *request, const char *host, const char *path, const char *body_bytes, size_t body_size, grpc_core::Timestamp deadline, grpc_closure *on_complete, grpc_http_response *response)
void DoRead() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
RefCountedPtr< HttpRequest > Ref() GRPC_MUST_USE_RESULT
const grpc_channel_args * channel_args_
void grpc_pollset_set_destroy(grpc_pollset_set *pollset_set)
static void OnRead(void *user_data, grpc_error_handle error)
void grpc_channel_args_destroy(grpc_channel_args *a)
const HandshakerRegistry & handshaker_registry() const
void grpc_endpoint_shutdown(grpc_endpoint *ep, grpc_error_handle why)
void grpc_http_parser_destroy(grpc_http_parser *)
size_type size() const noexcept
const grpc_channel_args * channel_args_
grpc_slice_buffer outgoing_
void grpc_endpoint_destroy(grpc_endpoint *ep)
GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer *sb)
#define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc)
#define GRPC_SLICE_LENGTH(slice)
constexpr const T & value() const &
void grpc_iomgr_register_object(grpc_iomgr_object *obj, const char *name)
const std::string & scheme() const
ABSL_MUST_USE_RESULT bool ok() const
GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice)
void AddHandshakers(HandshakerType handshaker_type, const grpc_channel_args *args, grpc_pollset_set *interested_parties, HandshakeManager *handshake_mgr) const
#define GRPC_ERROR_REF(err)
int(* grpc_httpcli_get_override)(const grpc_http_request *request, const char *host, const char *path, grpc_core::Timestamp deadline, grpc_closure *on_complete, grpc_http_response *response)
#define GRPC_ARG_TCP_HANDSHAKER_RESOLVED_ADDRESS
grpc_error_handle absl_status_to_grpc_error(absl::Status status)
static OrphanablePtr< HttpRequest > Get(URI uri, const grpc_channel_args *args, grpc_polling_entity *pollent, const grpc_http_request *request, Timestamp deadline, grpc_closure *on_done, grpc_http_response *response, RefCountedPtr< grpc_channel_credentials > channel_creds) GRPC_MUST_USE_RESULT
static void OnHandshakeDone(void *arg, grpc_error_handle error)
ResourceQuotaRefPtr ResourceQuotaFromChannelArgs(const grpc_channel_args *args)
DNSResolver * GetDNSResolver()
std::unique_ptr< T, Deleter > OrphanablePtr
void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity *pollent, grpc_pollset_set *pss_dst)
virtual TaskHandle ResolveName(absl::string_view name, absl::string_view default_port, grpc_pollset_set *interested_parties, std::function< void(absl::StatusOr< std::vector< grpc_resolved_address >>)> on_done)=0
void Finish(grpc_error_handle error) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
grpc_error_handle grpc_http_parser_parse(grpc_http_parser *parser, const grpc_slice &slice, size_t *start_of_body)
void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type, void *request_or_response)
#define GRPC_ERROR_UNREF(err)
void grpc_slice_buffer_destroy_internal(grpc_slice_buffer *sb)
void grpc_endpoint_write(grpc_endpoint *ep, grpc_slice_buffer *slices, grpc_closure *cb, void *arg, int max_frame_size)
grpc_pollset_set * pollset_set_
const T & value() const &ABSL_ATTRIBUTE_LIFETIME_BOUND
static OrphanablePtr< HttpRequest > Put(URI uri, const grpc_channel_args *args, grpc_polling_entity *pollent, const grpc_http_request *request, Timestamp deadline, grpc_closure *on_done, grpc_http_response *response, RefCountedPtr< grpc_channel_credentials > channel_creds) GRPC_MUST_USE_RESULT
virtual grpc_core::RefCountedPtr< grpc_channel_security_connector > create_security_connector(grpc_core::RefCountedPtr< grpc_call_credentials > call_creds, const char *target, const grpc_channel_args *args, grpc_channel_args **new_args)=0
const grpc_slice request_text_
std::unique_ptr< Parser > parser_
absl::StatusOr< std::string > grpc_sockaddr_to_uri(const grpc_resolved_address *resolved_addr)
static void TestOnlySetOnHandshakeDoneIntercept(void(*intercept)(HttpRequest *req))
grpc_channel_args * grpc_channel_args_copy_and_add(const grpc_channel_args *src, const grpc_arg *to_add, size_t num_to_add)
void grpc_slice_unref_internal(const grpc_slice &slice)
void StartWrite() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
grpc_polling_entity pollent_
#define GRPC_ERROR_IS_NONE(err)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:02