Skip to content
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
14 changes: 3 additions & 11 deletions proxy/http/HttpBodyFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ char *
HttpBodyFactory::fabricate_with_old_api(const char *type, HttpTransact::State *context, int64_t max_buffer_length,
int64_t *resulting_buffer_length, char *content_language_out_buf,
size_t content_language_buf_size, char *content_type_out_buf, size_t content_type_buf_size,
const char *format, va_list ap)
int format_size, const char *format)
{
char *buffer = nullptr;
const char *lang_ptr = nullptr;
Expand Down Expand Up @@ -124,16 +124,8 @@ HttpBodyFactory::fabricate_with_old_api(const char *type, HttpTransact::State *c
///////////////////////////////////////////
// check if we don't need to format body //
///////////////////////////////////////////
if (format) {
// The length from ink_bvsprintf includes the trailing NUL, so adjust the final
// length accordingly.
int l = ink_bvsprintf(nullptr, format, ap);
if (l <= max_buffer_length) {
buffer = (char *)ats_malloc(l);
*resulting_buffer_length = ink_bvsprintf(buffer, format, ap) - 1;
plain_flag = true;
}
}

buffer = (format == nullptr) ? nullptr : ats_strndup(format, format_size);
/////////////////////////////////////////////////////////
// try to fabricate the desired type of error response //
/////////////////////////////////////////////////////////
Expand Down
24 changes: 13 additions & 11 deletions proxy/http/HttpBodyFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "HttpTransact.h"
#include "Main.h"
#include "ts/RawHashTable.h"
#include "ts/ink_sprintf.h"

#define HTTP_BODY_TEMPLATE_MAGIC 0xB0DFAC00
#define HTTP_BODY_SET_MAGIC 0xB0DFAC55
Expand Down Expand Up @@ -156,21 +157,22 @@ class HttpBodyFactory
///////////////////////
char *fabricate_with_old_api(const char *type, HttpTransact::State *context, int64_t max_buffer_length,
int64_t *resulting_buffer_length, char *content_language_out_buf, size_t content_language_buf_size,
char *content_type_out_buf, size_t content_type_buf_size, const char *format, va_list ap);
char *content_type_out_buf, size_t content_type_buf_size, int format_size, const char *format);

char *
fabricate_with_old_api_build_va(const char *type, HttpTransact::State *context, int64_t max_buffer_length,
int64_t *resulting_buffer_length, char *content_language_out_buf,
size_t content_language_buf_size, char *content_type_out_buf, size_t content_type_buf_size,
const char *format, ...)
getFormat(int64_t max_buffer_length, int64_t *resulting_buffer_length, const char *format, ...)
{
char *msg;
char *msg = nullptr;
va_list ap;

va_start(ap, format);
msg = fabricate_with_old_api(type, context, max_buffer_length, resulting_buffer_length, content_language_out_buf,
content_language_buf_size, content_type_out_buf, content_type_buf_size, format, ap);
va_end(ap);
if (format) {
// The length from ink_bvsprintf includes the trailing NUL, so adjust the final
// length accordingly.
int l = ink_bvsprintf(nullptr, format, ap);
if (l <= max_buffer_length) {
msg = (char *)ats_malloc(l);
*resulting_buffer_length = ink_bvsprintf(msg, format, ap) - 1;
}
}
return msg;
}

Expand Down
6 changes: 2 additions & 4 deletions proxy/http/HttpSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3496,12 +3496,10 @@ HttpSM::tunnel_handler_post_ua(int event, HttpTunnelProducer *p)

switch (event) {
case VC_EVENT_INACTIVITY_TIMEOUT:
HttpTransact::build_error_response(&t_state, HTTP_STATUS_REQUEST_TIMEOUT, "POST Request timeout", "timeout#inactivity",
nullptr);
HttpTransact::build_error_response(&t_state, HTTP_STATUS_REQUEST_TIMEOUT, "POST Request timeout", "timeout#inactivity");
break;
case VC_EVENT_ACTIVE_TIMEOUT:
HttpTransact::build_error_response(&t_state, HTTP_STATUS_REQUEST_TIMEOUT, "POST Request timeout", "timeout#activity",
nullptr);
HttpTransact::build_error_response(&t_state, HTTP_STATUS_REQUEST_TIMEOUT, "POST Request timeout", "timeout#activity");
break;
}

Expand Down
Loading