Archive: inetc::post "issue"


inetc::post "issue"
  Hello guys.

I've been trying to use the inetc plug-in to send a xml file content via POST to a webpage...
This xml file is created via NSIS as well using plain FileOpen / FileWrite commands.

I noticed that I get 500 - Internal server error when I'm trying to send it. It troubled me for a long while, since I was able to send plain text before just fine...

Then I finally pointed it out: something bad happens when I'm sending "<" (less than) and ">" (greater than) characters via POST.

I don't know if any of you guys ever had this issue (and I searched the forums for a good while before posting this), but do you know a better way to avoid it other than creating a XML with "=lt;" and "=gt;" to replace the "<" and ">" characters?

Yeah, "&" also gave me the same issue. "&lt;" and "&gt;" didn't work either.

Since I'm already posting, I might just ask something else:

FileRead only reads each line at a time from a file, in order to send in the whole file content, I'm concatenating each line I read in a loop on a variable.

I noticed the /FILE option while using inetc:: post. How do you use it? Do you put the file path "TEXT2POST" parameter?

As in:


inetc::post "C:\Users\Blah\Desktop\test.txt" /FILE /SILENT "http://localhost/PostReceiver.aspx" "$DOCUMENTS\post_reply.htm" /END 

>
Thanks in advance.

Yes, following line sends file to server and puts reply to htm file


inetc::post "$EXEDIR\inetc.cpp" /file "http://localhost/post_file.php" "$EXEDIR\post_file.htm"
It looks like NSI script sample was lost, but post_file.php included to package (server part of sample).
And yes, we send header "Content-Type: application/x-www-form-urlencoded" to server, so it expects encoded string. But with /file sample right now I could send and return CPP file with a lot of &, < and >. I don't have clear understanding what headers to use in particular case (string, string with special chars, form, binary file), but "urlencoded" header was there from the very beginning. May be you will can overwrite 'Content-type' with /header option - it sets additional header after regulat POST header was added. If you have info - please send me and I'll test variants...

Hi, Takhir. Thanks for replying :D

I used the /FILE option with my modified xml (without <, > and &) and inet:: post worked just fine...

But when I tried sending it without modifying it, there's no response at all. I verified the header contents and saw that the Content-Type is set to application/x-www-form-urlencoded just fine.

Yet, there was no response at all. It just gives me that blasted 500 error.

I'm attaching the original xml file I'm trying to post, if it helps.


I wrote earlier that this /file option was added 'by request' and is not 'canonical' implementation. Another word it is kind of patch. It was tested with PHP script handling http input and this way it worked correct for the moment. I tested your file with post_file.php script on the server and could see file content in server reply (no modifications). Inetc sends file with http POST request 'as it is'. I remember, that when I tested this feature, POST was rejected by server without any other content-type header except application/x-www-form-urlencoded. May be I am wrong...


Well, can you attach this post_file.php you wrote? I'd like to compare it to the page I'm using as test.


500 error could mean you have some unhandled exception in your script. Check your phperrors.log file.

Stu


PHP file attached. It is also included to Inetc.zip package http://nsis.sourceforge.net/File:Inetc.zip