Skip to content

Commit d5bf673

Browse files
committed
Merge branch 'master' into stricten_chunk_parser
Conflicts: include/proxy/http/HttpTunnel.h src/proxy/http/HttpTunnel.cc
2 parents cd40bee + 286acc0 commit d5bf673

File tree

92 files changed

+2746
-2568
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2746
-2568
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
2424
endif()
2525

2626
cmake_minimum_required(VERSION 3.20..3.27)
27-
project(ats VERSION 10.1.0)
27+
project(ats VERSION 10.2.0)
2828

2929
set(TS_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
3030
set(TS_VERSION_MINOR ${PROJECT_VERSION_MINOR})

doc/admin-guide/files/index.en.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Configuration Files
5757
Defines custom log file formats, filters, and processing options.
5858

5959
:doc:`parent.config.en`
60-
Configures parent proxies in hierarchical caching layouts.
60+
Configures parent proxies in hierarchical caching layouts. Deprecated in `TS` 10.1, and replaced with strategies.yaml in 11.
6161

6262
:doc:`plugin.config.en`
6363
Control runtime loadable plugins available to |TS|, as well as their
@@ -83,7 +83,7 @@ Configuration Files
8383
Configures all storage devices and paths to be used for the |TS| cache.
8484

8585
:doc:`strategies.yaml.en`
86-
Configures NextHop strategies used with `remap.config`
86+
Configures NextHop strategies used with `remap.config` and replaces parent.config.
8787

8888
:doc:`volume.config.en`
8989
Defines cache space usage by individual protocols.

doc/admin-guide/plugins/compress.en.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,21 @@ by the origin. Enabled by default.
106106
range-request
107107
-------------
108108

109-
When set to ``true``, causes |TS| to compress responses to Range Requests.
110-
Disabled by default. Setting this to true while setting cache to false leads to delivering corrupted content.
109+
This config controls behavior of this plugin when a client send ``Range`` header and ``Accept-Encoding`` header in the same time.
110+
111+
============== =================================================================
112+
Value Description
113+
============== =================================================================
114+
ignore-range Remove ``Range`` header if the request has both headers (Default)
115+
false Same as ``ignore-range`` for compatiblity
116+
no-compression Remove ``Accept-Encoding`` header if the request has both headers
117+
none Do nothing
118+
true Same as ``none`` for compatibility
119+
============== =================================================================
120+
121+
.. important::
122+
123+
Do NOT set this to ``none`` (or ``true``) if the cache config is set to ``false``. This combination will deliver corrupted content.
111124

112125
compressible-content-type
113126
-------------------------

doc/admin-guide/plugins/header_rewrite.en.rst

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ with the word ``else``. The following example illustrates this::
140140
The ``else`` clause is not a condition, and does not take any flags, it is
141141
of course optional, but when specified must be followed by at least one operator.
142142

143+
State variables
144+
---------------
145+
146+
A set of state variables are also available for both conditions and operators.
147+
There are currently 16 flag states, 4 8-bit integers and one 16-bit integer states.
148+
These states are all transactional, meaning they are usable and persistent across
149+
all hooks.
150+
151+
The flag states are numbers 0-15, the 8-bit integer states are numbered 0-3, and the
152+
one 16-bit integer state is number 0.
153+
143154
Conditions
144155
----------
145156

@@ -457,9 +468,10 @@ As a special matcher, the inbound IP addresses can be matched against a list of
457468

458469
cond %{INBOUND:REMOTE-ADDR} {192.168.201.0/24,10.0.0.0/8}
459470

460-
Note that this will not work against the non-IP based conditions, such as the protocol families,
461-
and the configuration parser will error out. The format here is very specific, in particular no
462-
white spaces are allowed between the ranges.
471+
.. note::
472+
This will not work against the non-IP based conditions, such as the protocol families,
473+
and the configuration parser will error out. The format here is very specific, in particular no
474+
white spaces are allowed between the ranges.
463475

464476
IP
465477
~~
@@ -569,6 +581,36 @@ RANDOM
569581

570582
Generates a random integer from ``0`` up to (but not including) ``<n>``. Mathematically, ``[0,n)`` or ``0 <= r < n``.
571583

584+
STATE-FLAG
585+
~~~~~~~~~~
586+
::
587+
588+
cond %{STATE-FLAG:<n>}
589+
590+
This condition allows you to check the state of a flag. The ``<n>`` is the
591+
number of the flag, from 0 to 15. This condition returns a ``true`` or
592+
``false`` value, depending on the state of the flag.
593+
594+
STATE-INT8
595+
~~~~~~~~~~
596+
::
597+
598+
cond %{STATE-INT8:<n>}
599+
600+
This condition allows you to check the state of an 8-bit unsigned integer.
601+
The ``<n>`` is the number of the integer, from 0 to 3. The current value of
602+
the state integer is returned, and all 4 integers are initialized to 0.
603+
604+
STATE-INT16
605+
~~~~~~~~~~~
606+
::
607+
608+
cond %{STATE-INT16<:0>}
609+
610+
This condition allows you to check the state of an 16-bit unsigned integer.
611+
There's only one such integer, and its value is returned from this condition.
612+
As such, the index, ``0``, is optional here.
613+
572614
STATUS
573615
~~~~~~
574616
::
@@ -920,6 +962,38 @@ location automatically. This operator supports `String concatenations`_ for
920962
``READ_RESPONSE_HDR_HOOK`` (the default when the plugin is global), the
921963
``SEND_RESPONSE_HDR_HOOK``, or the ``REMAP_PSEUDO_HOOK``.
922964

965+
set-state-flag
966+
~~~~~~~~~~~~~~
967+
::
968+
969+
set-state-flag <n> <value>
970+
971+
This operator allows you to set the state of a flag. The ``<n>`` is the
972+
number of the flag, from 0 to 15. The ``<value>`` is either ``true`` or ``false``,
973+
turning the flag on or off.
974+
975+
set-state-int8
976+
~~~~~~~~~~~~~~
977+
::
978+
979+
set-state-int8 <n> <value>
980+
981+
This operator allows you to set the state of an 8-bit unsigned integer.
982+
The ``<n>`` is the number of the integer, from 0 to 3. The ``<value>`` is an
983+
unsigned 8-bit integer, 0-255. It can also be a condition, in which case the
984+
value of the condition is used.
985+
986+
set-state-int16
987+
~~~~~~~~~~~~~~~
988+
::
989+
990+
set-state-int16 0 <value>
991+
992+
This operator allows you to set the state of a 16-bit unsigned integer.
993+
The ``<value>`` is an unsigned 16-bit integer as well, 0-65535. It can also
994+
be a condition, in which case thevalue of the condition is used. The index,
995+
0, is always required eventhough there is only one 16-bit integer state variable.
996+
923997
set-status
924998
~~~~~~~~~~
925999
::
@@ -1438,6 +1512,11 @@ could each be tagged with a consistent name to make finding logs easier.::
14381512

14391513
(Then in :file:`logging.yaml`, log ``%<{@PropertyName}cqh>``)
14401514

1515+
.. note::
1516+
With the new ``state-flag``, ``state-int8`` and ``state-int16`` operators, you can
1517+
sometimes avoid setting internal ``@`` headers for passing information between hooks.
1518+
These internal state variables are much more efficient than setting and reading headers.
1519+
14411520
Remove Client Query Parameters
14421521
------------------------------------
14431522

include/proxy/hdrs/HTTP.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ class HTTPHdr : public MIMEHdr
485485
mutable int m_port = 0; ///< Target port.
486486
mutable bool m_target_cached = false; ///< Whether host name and port are cached.
487487
mutable bool m_target_in_url = false; ///< Whether host name and port are in the URL.
488+
mutable bool m_100_continue_sent = false; ///< Whether ATS sent a 100 Continue optimized response.
488489
mutable bool m_100_continue_required = false; ///< Whether 100_continue is in the Expect header.
489490
/// Set if the port was effectively specified in the header.
490491
/// @c true if the target (in the URL or the HOST field) also specified

include/proxy/hdrs/MIME.h

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ struct MIMEField {
143143

144144
/// @return The name of @a this field.
145145
std::string_view name_get() const;
146-
const char *name_get(int *length) const;
147146

148147
/** Find the index of the value in the multi-value field.
149148
@@ -161,7 +160,6 @@ struct MIMEField {
161160

162161
/// @return The value of @a this field.
163162
std::string_view value_get() const;
164-
const char *value_get(int *length) const;
165163

166164
int32_t value_get_int() const;
167165
uint32_t value_get_uint() const;
@@ -940,17 +938,6 @@ bool mime_parse_integer(const char *&buf, const char *end, int *integer);
940938
* *
941939
***********************************************************************/
942940

943-
/*-------------------------------------------------------------------------
944-
-------------------------------------------------------------------------*/
945-
946-
inline const char *
947-
MIMEField::name_get(int *length) const
948-
{
949-
auto name{this->name_get()};
950-
*length = int(name.size());
951-
return name.data();
952-
}
953-
954941
/*-------------------------------------------------------------------------
955942
-------------------------------------------------------------------------*/
956943

@@ -974,11 +961,9 @@ MIMEField::name_set(HdrHeap *heap, MIMEHdrImpl *mh, const char *name, int length
974961
inline bool
975962
MIMEField::name_is_valid(uint32_t invalid_char_bits) const
976963
{
977-
const char *name;
978-
int length;
979-
980-
for (name = name_get(&length); length > 0; length--) {
981-
if (ParseRules::is_type(name[length - 1], invalid_char_bits)) {
964+
auto name{name_get()};
965+
for (auto c : name) {
966+
if (ParseRules::is_type(c, invalid_char_bits)) {
982967
return false;
983968
}
984969
}
@@ -988,14 +973,6 @@ MIMEField::name_is_valid(uint32_t invalid_char_bits) const
988973
/*-------------------------------------------------------------------------
989974
-------------------------------------------------------------------------*/
990975

991-
inline const char *
992-
MIMEField::value_get(int *length) const
993-
{
994-
auto value{this->value_get()};
995-
*length = int(value.size());
996-
return value.data();
997-
}
998-
999976
inline int32_t
1000977
MIMEField::value_get_int() const
1001978
{
@@ -1083,11 +1060,9 @@ MIMEField::value_append(HdrHeap *heap, MIMEHdrImpl *mh, const char *value, int l
10831060
inline bool
10841061
MIMEField::value_is_valid(uint32_t invalid_char_bits) const
10851062
{
1086-
const char *value;
1087-
int length;
1088-
1089-
for (value = value_get(&length); length > 0; length--) {
1090-
if (ParseRules::is_type(value[length - 1], invalid_char_bits)) {
1063+
auto value{value_get()};
1064+
for (auto c : value) {
1065+
if (ParseRules::is_type(c, invalid_char_bits)) {
10911066
return false;
10921067
}
10931068
}
@@ -1449,7 +1424,9 @@ MIMEHdr::value_get(const char *name, int name_length, int *value_length_return)
14491424
const MIMEField *field = field_find(name, name_length);
14501425

14511426
if (field) {
1452-
return field->value_get(value_length_return);
1427+
auto value{field->value_get()};
1428+
*value_length_return = static_cast<int>(value.length());
1429+
return value.data();
14531430
}
14541431
return nullptr;
14551432
}
@@ -1581,12 +1558,10 @@ MIMEHdr::field_combine_dups(MIMEField *field, bool prepend_comma, const char sep
15811558
MIMEField *current = field->m_next_dup;
15821559

15831560
while (current) {
1584-
int value_len = 0;
1585-
const char *value_str = current->value_get(&value_len);
1586-
1587-
if (value_len > 0) {
1588-
HdrHeap::HeapGuard guard(m_heap, value_str); // reference count the source string so it doesn't get moved
1589-
field->value_append(m_heap, m_mime, value_str, value_len, prepend_comma, separator);
1561+
auto value{current->value_get()};
1562+
if (value.length() > 0) {
1563+
HdrHeap::HeapGuard guard(m_heap, value.data()); // reference count the source string so it doesn't get moved
1564+
field->value_append(m_heap, m_mime, value.data(), value.length(), prepend_comma, separator);
15901565
}
15911566
field_delete(current, false); // don't delete duplicates
15921567
current = field->m_next_dup;

include/proxy/http/HttpSM.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class PostDataBuffers
153153

154154
void clear();
155155
void init(IOBufferReader *ua_reader);
156-
void copy_partial_post_data();
156+
int64_t copy_partial_post_data(int64_t consumed_bytes);
157157
IOBufferReader *get_post_data_buffer_clone_reader();
158158
void
159159
set_post_data_buffer_done(bool done)
@@ -287,7 +287,7 @@ class HttpSM : public Continuation, public PluginUserArgs<TS_USER_ARGS_TXN>
287287
char *redirect_url = nullptr; // url for force redirect (provide users a functionality to redirect to another url when needed)
288288
int redirect_url_len = 0;
289289
int redirection_tries = 0; // To monitor number of redirections
290-
int64_t transfered_bytes = 0; // Added to calculate POST data
290+
int64_t transferred_bytes = 0; // For handling buffering of request body data.
291291

292292
BackgroundFill_t background_fill = BACKGROUND_FILL_NONE;
293293

@@ -317,7 +317,7 @@ class HttpSM : public Continuation, public PluginUserArgs<TS_USER_ARGS_TXN>
317317
int64_t postbuf_buffer_avail();
318318
void postbuf_clear();
319319
void disable_redirect();
320-
void postbuf_copy_partial_data();
320+
int64_t postbuf_copy_partial_data(int64_t consumed_bytes);
321321
void postbuf_init(IOBufferReader *ua_reader);
322322
void set_postbuf_done(bool done);
323323
IOBufferReader *get_postbuf_clone_reader();
@@ -764,10 +764,10 @@ HttpSM::disable_redirect()
764764
this->_postbuf.clear();
765765
}
766766

767-
inline void
768-
HttpSM::postbuf_copy_partial_data()
767+
inline int64_t
768+
HttpSM::postbuf_copy_partial_data(int64_t consumed_bytes)
769769
{
770-
this->_postbuf.copy_partial_post_data();
770+
return this->_postbuf.copy_partial_post_data(consumed_bytes);
771771
}
772772

773773
inline void

0 commit comments

Comments
 (0)