[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [hobbit] Content-Type header for HTTP POST (was: Xymon 4.3.0: Beta version available on Sourceforge)



On Tue, Mar 03, 2009 at 05:18:53PM +0100, Frank Gruellich wrote:
> Hi,
>
> Henrik St?rner wrote:
>> * Make the content-type setting in HTTP POST tests configurable.
>
> I tried to make that feature working today, but I can't figure out how
> to use it.  That's what I tried to configure after reading
>
>               If  your  form-data  requires  a different content-type, you can
>               specify it by beginning the form-data with  (content-type=TYPE),
>               e.g.  "(content-type=text/xml)"  followed by the POST data.
>
> in bb-hosts:
>
> 10.35.12.31	jupiter	# post;http://10.35.12.31/some/application;(content-type=text/xml)<soapenv><lots_of_stuff></lots_of_stuff><soapenv>
>
> I also tried without parentheses to no avail.  tcpdumping around shows
> that (content-type=text/xml) is quoted directly into the POST and the
> default application/x-www-form-urlencoded is still there.  What am I
> doing wrong?

Nothing. It's a bug. The attached patch should fix it, this works on
all 4.2.x versions out there.

However, SOAP usually requires an extra header (SOAPAction), and the 
4.2.x version of Xymon won't generate that. You'll need the 4.3.0
version (in beta, and a new beta is coming shortly) and then you 
can use the built-in SOAP test for it.


Regards,
Henrik

Index: bbnet/httptest.c
===================================================================
--- bbnet/httptest.c	(revision 6161)
+++ bbnet/httptest.c	(working copy)
@@ -590,11 +590,17 @@
 	addtobuffer(httprequest, "\r\n");
 
 	if (httptest->bburl.postdata) {
-		char contlenhdr[100];
+		char hdr[100];
+		int contlen = strlen(httptest->bburl.postdata);
 
-		sprintf(contlenhdr, "Content-Length: %d\r\n", strlen(httptest->bburl.postdata));
-		addtobuffer(httprequest, contlenhdr);
-		addtobuffer(httprequest, "Content-Type: application/x-www-form-urlencoded\r\n");
+		addtobuffer(httprequest, "Content-Type: ");
+		if      (httptest->bburl.postcontenttype)
+			addtobuffer(httprequest, httptest->bburl.postcontenttype);
+		else
+			addtobuffer(httprequest, "application/x-www-form-urlencoded");
+		addtobuffer(httprequest, "\r\n");
+		sprintf(hdr, "Content-Length: %d\r\n", contlen);
+		addtobuffer(httprequest, hdr);
 	}
 	{
 		char useragent[100];