This is an automated email from the ASF dual-hosted git repository.
amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new cb27276 YAML: LibSWOC prep - update BufferWriter logic in
HttpTransactHeaders.cc
cb27276 is described below
commit cb2727667511b803d0bf664da42a660de0411fe7
Author: Alan M. Carroll <[email protected]>
AuthorDate: Sat Oct 20 15:30:56 2018 -0500
YAML: LibSWOC prep - update BufferWriter logic in HttpTransactHeaders.cc
---
proxy/http/HttpTransactHeaders.cc | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/proxy/http/HttpTransactHeaders.cc
b/proxy/http/HttpTransactHeaders.cc
index 95f6626..5f18843 100644
--- a/proxy/http/HttpTransactHeaders.cc
+++ b/proxy/http/HttpTransactHeaders.cc
@@ -1155,25 +1155,19 @@
HttpTransactHeaders::add_forwarded_field_to_request(HttpTransact::State *s, HTTP
if (n_proto > 0) {
auto Conn = [&](HttpForwarded::Option opt,
HttpTransactHeaders::ProtocolStackDetail detail) -> void {
- if (optSet[opt]) {
- int revert = hdr.size();
+ if (optSet[opt] && hdr.remaining() > 0) {
+ ts::FixedBufferWriter lw{hdr.auxBuffer(), hdr.remaining()};
if (hdr.size()) {
- hdr << ';';
+ lw << ';';
}
- hdr << "connection=";
+ lw << "connection=";
int numChars =
- HttpTransactHeaders::write_hdr_protocol_stack(hdr.auxBuffer(),
hdr.remaining(), detail, protoBuf.data(), n_proto, '-');
- if (numChars > 0) {
- hdr.fill(size_t(numChars));
- }
-
- if ((numChars <= 0) or (hdr.size() >= hdr.capacity())) {
- // Remove parameter with potentially incomplete value.
- //
- hdr.reduce(revert);
+ HttpTransactHeaders::write_hdr_protocol_stack(lw.auxBuffer(),
lw.remaining(), detail, protoBuf.data(), n_proto, '-');
+ if (numChars > 0 && !lw.fill(size_t(numChars)).error()) {
+ hdr.fill(lw.size());
}
}
};