Wednesday, August 26, 2015

Posting to HTTP listener with Firefox poster vs html form submit

I have a simple Mule application listens for http on port 8088. When I use Firefox poster to post up data, it sends in pure payload (in this case text/xml). And the application is happy to process the data.

Naturally I was thinking why go through Firefox poster each time, so I created a simple html file with a form post, something like

<form method="post" action="myserver:8088/mypath">
  enter data below
  <textarea cols=20 row=20>
  <input type='submit'>

I ran into several issues, and decided to give up. I may come back later to see there is an actual work around. For now, this post just reminds what NOT to do. Because I have already attempted this twice in 6 weeks. Need to remind myself stopping making the same mistake.

Issue 1: as it appears above, <textarea> has no name, so I don't know what got posted up to the server, Mule application picked up a "null" payload. I believe it posted something, i just didn't spend time to track it. Maybe I'll track it some other day.

Issue 2: I added <textarea name="foo"...>
Now the application picked up the payload, except the payload is "foo=<xml....>", I need the payload to be pure xml like "<xml ...>" so no go :(

Issue 3: I tried to give it a name with just a space like <textarea name=' '...>, didn't go very far either, the payload shows up as " =<xml ...>".

couple other things I looked into:

apparently, firefox poster posts the content up as "content-type=text/xml", but I don't seem to have control over that with HTML form. "enctype" only has 3 options, the closest is "text/plain", no cigar here.

Until I have too much time on my hand to tinker around it, I'm staying with Firefox poster for now.

No comments:

Post a Comment