Skip to content
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

zhttppacket: add router-resp #48076

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/connmgr/zhttppacket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ pub struct RequestData<'buf, 'headers> {
pub credits: u32,
pub more: bool,
pub stream: bool,
pub router_resp: bool,
pub max_size: u32,
pub timeout: u32,
pub method: &'buf str,
Expand All @@ -349,6 +350,7 @@ impl RequestData<'_, '_> {
credits: 0,
more: false,
stream: false,
router_resp: false,
max_size: 0,
timeout: 0,
method: "",
Expand Down Expand Up @@ -425,6 +427,11 @@ impl<'a> Serialize<'a> for RequestData<'a, 'a> {
w.write_bool(true)?;
}

if self.router_resp {
w.write_string(b"router-resp")?;
w.write_bool(true)?;
}

if self.max_size > 0 {
w.write_string(b"max-size")?;
w.write_int(self.max_size as isize)?;
Expand Down Expand Up @@ -457,6 +464,7 @@ impl<'buf: 'scratch, 'scratch> Parse<'buf, 'scratch> for RequestData<'buf, 'scra
let mut credits = 0;
let mut more = false;
let mut stream = false;
let mut router_resp = false;
let mut max_size = 0;
let mut timeout = 0;
let mut method = "";
Expand Down Expand Up @@ -495,6 +503,11 @@ impl<'buf: 'scratch, 'scratch> Parse<'buf, 'scratch> for RequestData<'buf, 'scra

stream = b;
}
"router-resp" => {
let b = tnetstring::parse_bool(e.data).field("router-resp")?;

router_resp = b;
}
"max-size" => {
let x = tnetstring::parse_int(e.data).field("max-size")?;

Expand Down Expand Up @@ -641,6 +654,7 @@ impl<'buf: 'scratch, 'scratch> Parse<'buf, 'scratch> for RequestData<'buf, 'scra
credits,
more,
stream,
router_resp,
max_size,
timeout,
method,
Expand Down Expand Up @@ -1783,6 +1797,7 @@ mod tests {
credits: 0,
more: true,
stream: false,
router_resp: false,
max_size: 0,
timeout: 0,
method: "POST",
Expand Down
12 changes: 12 additions & 0 deletions src/core/zhttprequestpacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ QVariant ZhttpRequestPacket::toVariant() const
if(stream)
obj["stream"] = true;

if(routerResp)
obj["router-resp"] = true;

if(maxSize != -1)
obj["max-size"] = maxSize;

Expand Down Expand Up @@ -309,6 +312,15 @@ bool ZhttpRequestPacket::fromVariant(const QVariant &in)
stream = obj["stream"].toBool();
}

routerResp = false;
if(obj.contains("router-resp"))
{
if(typeId(obj["router-resp"]) != QMetaType::Bool)
return false;

routerResp = obj["router-resp"].toBool();
}

maxSize = -1;
if(obj.contains("max-size"))
{
Expand Down
3 changes: 3 additions & 0 deletions src/core/zhttprequestpacket.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012-2016 Fanout, Inc.
* Copyright (C) 2024 Fastly, Inc.
*
* $FANOUT_BEGIN_LICENSE:APACHE2$
*
Expand Down Expand Up @@ -70,6 +71,7 @@ class ZhttpRequestPacket
int credits;
bool more;
bool stream;
bool routerResp;
int maxSize;
int timeout;

Expand Down Expand Up @@ -101,6 +103,7 @@ class ZhttpRequestPacket
credits(-1),
more(false),
stream(false),
routerResp(false),
maxSize(-1),
timeout(-1),
code(-1),
Expand Down