src: Simplify function parameter using StringRef
This commit is contained in:
parent
3f2b54cfc4
commit
e302cc9c16
|
@ -1848,11 +1848,10 @@ bool Http2Upstream::push_enabled() const {
|
||||||
get_config()->http2_proxy);
|
get_config()->http2_proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Http2Upstream::initiate_push(Downstream *downstream, const char *uri,
|
int Http2Upstream::initiate_push(Downstream *downstream, const StringRef &uri) {
|
||||||
size_t len) {
|
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (len == 0 || !push_enabled() || (downstream->get_stream_id() % 2)) {
|
if (uri.empty() || !push_enabled() || (downstream->get_stream_id() % 2)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1866,8 +1865,7 @@ int Http2Upstream::initiate_push(Downstream *downstream, const char *uri,
|
||||||
const std::string *scheme_ptr, *authority_ptr;
|
const std::string *scheme_ptr, *authority_ptr;
|
||||||
std::string scheme, authority, path;
|
std::string scheme, authority, path;
|
||||||
|
|
||||||
rv = http2::construct_push_component(scheme, authority, path, base,
|
rv = http2::construct_push_component(scheme, authority, path, base, uri);
|
||||||
StringRef{uri, len});
|
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,7 @@ public:
|
||||||
virtual int on_downstream_reset(bool no_retry);
|
virtual int on_downstream_reset(bool no_retry);
|
||||||
virtual int send_reply(Downstream *downstream, const uint8_t *body,
|
virtual int send_reply(Downstream *downstream, const uint8_t *body,
|
||||||
size_t bodylen);
|
size_t bodylen);
|
||||||
virtual int initiate_push(Downstream *downstream, const char *uri,
|
virtual int initiate_push(Downstream *downstream, const StringRef &uri);
|
||||||
size_t len);
|
|
||||||
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
|
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
|
||||||
virtual void response_drain(size_t n);
|
virtual void response_drain(size_t n);
|
||||||
virtual bool response_empty() const;
|
virtual bool response_empty() const;
|
||||||
|
|
|
@ -1153,8 +1153,7 @@ fail:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int HttpsUpstream::initiate_push(Downstream *downstream, const char *uri,
|
int HttpsUpstream::initiate_push(Downstream *downstream, const StringRef &uri) {
|
||||||
size_t len) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,7 @@ public:
|
||||||
virtual int on_downstream_reset(bool no_retry);
|
virtual int on_downstream_reset(bool no_retry);
|
||||||
virtual int send_reply(Downstream *downstream, const uint8_t *body,
|
virtual int send_reply(Downstream *downstream, const uint8_t *body,
|
||||||
size_t bodylen);
|
size_t bodylen);
|
||||||
virtual int initiate_push(Downstream *downstream, const char *uri,
|
virtual int initiate_push(Downstream *downstream, const StringRef &uri);
|
||||||
size_t len);
|
|
||||||
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
|
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
|
||||||
virtual void response_drain(size_t n);
|
virtual void response_drain(size_t n);
|
||||||
virtual bool response_empty() const;
|
virtual bool response_empty() const;
|
||||||
|
|
|
@ -291,7 +291,7 @@ mrb_value request_push(mrb_state *mrb, mrb_value self) {
|
||||||
mrb_int len;
|
mrb_int len;
|
||||||
mrb_get_args(mrb, "s", &uri, &len);
|
mrb_get_args(mrb, "s", &uri, &len);
|
||||||
|
|
||||||
upstream->initiate_push(downstream, uri, len);
|
upstream->initiate_push(downstream, StringRef{uri, static_cast<size_t>(len)});
|
||||||
|
|
||||||
return mrb_nil_value();
|
return mrb_nil_value();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1252,8 +1252,7 @@ int SpdyUpstream::on_downstream_reset(bool no_retry) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpdyUpstream::initiate_push(Downstream *downstream, const char *uri,
|
int SpdyUpstream::initiate_push(Downstream *downstream, const StringRef &uri) {
|
||||||
size_t len) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,7 @@ public:
|
||||||
|
|
||||||
virtual int send_reply(Downstream *downstream, const uint8_t *body,
|
virtual int send_reply(Downstream *downstream, const uint8_t *body,
|
||||||
size_t bodylen);
|
size_t bodylen);
|
||||||
virtual int initiate_push(Downstream *downstream, const char *uri,
|
virtual int initiate_push(Downstream *downstream, const StringRef &uri);
|
||||||
size_t len);
|
|
||||||
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
|
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
|
||||||
virtual void response_drain(size_t n);
|
virtual void response_drain(size_t n);
|
||||||
virtual bool response_empty() const;
|
virtual bool response_empty() const;
|
||||||
|
|
|
@ -68,8 +68,7 @@ public:
|
||||||
virtual int send_reply(Downstream *downstream, const uint8_t *body,
|
virtual int send_reply(Downstream *downstream, const uint8_t *body,
|
||||||
size_t bodylen) = 0;
|
size_t bodylen) = 0;
|
||||||
|
|
||||||
virtual int initiate_push(Downstream *downstream, const char *uri,
|
virtual int initiate_push(Downstream *downstream, const StringRef &uri) = 0;
|
||||||
size_t len) = 0;
|
|
||||||
|
|
||||||
// Fills response data in |iov| whose capacity is |iovcnt|. Returns
|
// Fills response data in |iov| whose capacity is |iovcnt|. Returns
|
||||||
// the number of iovs filled.
|
// the number of iovs filled.
|
||||||
|
|
Loading…
Reference in New Issue