bneradt commented on code in PR #13415:
URL: https://github.com/apache/trafficserver/pull/13415#discussion_r3717552178


##########
plugins/header_rewrite/operators.cc:
##########
@@ -58,11 +66,25 @@ handleFetchEvents(TSCont cont, TSEvent event, void *edata)
 
       TSHttpHdrTypeSet(hdr_buf, hdr_loc, TS_HTTP_TYPE_RESPONSE);
       if (TSHttpHdrParseResp(parser, hdr_buf, hdr_loc, &data_start, data_end) 
== TS_PARSE_DONE) {
-        size_t body_len = data_end - data_start;
-        char  *body     = static_cast<char *>(TSmalloc(body_len + 1));
+        char  *content_type = nullptr;
+        size_t body_len     = data_end - data_start;
+        char  *body         = static_cast<char *>(TSmalloc(body_len + 1));
+
+        if (!fetch_data->content_type.empty()) {
+          content_type = TSstrdup(fetch_data->content_type.c_str());
+        } else if (TSMLoc field_loc = TSMimeHdrFieldFind(hdr_buf, hdr_loc, 
TS_MIME_FIELD_CONTENT_TYPE, TS_MIME_LEN_CONTENT_TYPE);
+                   field_loc != TS_NULL_MLOC) {
+          int         value_len = 0;
+          const char *value     = TSMimeHdrFieldValueStringGet(hdr_buf, 
hdr_loc, field_loc, -1, &value_len);
+
+          if (value != nullptr && value_len > 0) {
+            content_type = TSstrndup(value, value_len);
+          }
+          TSHandleMLocRelease(hdr_buf, hdr_loc, field_loc);
+        }

Review Comment:
   Thanks, but ATS intentionally accepts either a MIME-header or HTTP-header 
locator in these APIs. Both functions validate both handle types, and the 
implementation obtains the embedded MIME header from the HTTP locator. There is 
no TSHttpHdrMimeGet() API. The header_rewrite_set_body_from AuTest also 
verifies propagation of the fetched Content-Type and passes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to