Add support for content-type in a POST method.
Submitted by: Philippe Marzouk <phil ozigo.org>
Reviewed by: Aaron Bannert
git-svn-id: https://svn.apache.org/repos/asf/httpd/test/trunk/flood@103023 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/config.h.in b/config.h.in
index 56bbc03..ac2f754 100644
--- a/config.h.in
+++ b/config.h.in
@@ -22,6 +22,7 @@
#define XML_URLLIST_METHOD_POST "post"
#define XML_URLLIST_METHOD_HEAD "head"
#define XML_URLLIST_PAYLOAD "payload"
+#define XML_URLLIST_CONTENT_TYPE "content-type"
#define XML_URLLIST_PAYLOAD_TEMPLATE "payloadtemplate"
#define XML_URLLIST_REQUEST_TEMPLATE "requesttemplate"
#define XML_URLLIST_RESPONSE_TEMPLATE "responsetemplate"
diff --git a/flood_profile.h b/flood_profile.h
index 8daa504..21719cb 100644
--- a/flood_profile.h
+++ b/flood_profile.h
@@ -69,6 +69,9 @@
/* Following only valid when method == POST */
apr_size_t payloadsize;
void * payload;
+
+ apr_size_t contenttypesize;
+ char * contenttype;
apr_uri_t *parsed_uri;
diff --git a/flood_round_robin.c b/flood_round_robin.c
index cc6d63e..5492d7c 100644
--- a/flood_round_robin.c
+++ b/flood_round_robin.c
@@ -70,6 +70,7 @@
char *url;
method_e method;
char *payload;
+ char *contenttype;
apr_int64_t predelay;
apr_int64_t predelayprecision;
apr_int64_t postdelay;
@@ -307,7 +308,7 @@
"Connection: %s" CRLF
"Host: %s" CRLF
"Content-Length: %d" CRLF
- "Content-type: application/x-www-form-urlencoded" CRLF
+ "Content-type: %s" CRLF
"%s"
"%s" CRLF
"%s",
@@ -317,6 +318,7 @@
r->keepalive ? "Keep-Alive" : "Close",
r->parsed_uri->hostinfo,
r->payloadsize,
+ r->contenttype ? r->contenttype : "application/x-www-form-urlencoded",
authz_hdr ? authz_hdr : "",
cookies,
(char*)r->payload);
@@ -393,6 +395,10 @@
FLOOD_STRLEN_MAX) == 0) {
url->payload = (char*)attr->value;
}
+ else if (strncasecmp(attr->name,XML_URLLIST_CONTENT_TYPE,
+ FLOOD_STRLEN_MAX) == 0) {
+ url->contenttype = (char*)attr->value;
+ }
else if (strncasecmp(attr->name, XML_URLLIST_PREDELAY,
FLOOD_STRLEN_MAX) == 0) {
char *endptr;
@@ -488,6 +494,7 @@
{
url->method = GET;
url->payload = NULL;
+ url->contenttype = NULL;
}
return APR_SUCCESS;
@@ -784,6 +791,12 @@
r->payloadsize = strlen(r->payload);
}
+ if (rp->url[rp->current_url].contenttype)
+ {
+ r->contenttype = parse_param_string(rp, rp->url[rp->current_url].contenttype);
+ r->contenttypesize = strlen(r->contenttype);
+ }
+
/* If they want a sleep, do it now. */
if (rp->url[rp->current_url].predelay) {
apr_int64_t real_predelay = rp->url[rp->current_url].predelay;