Old 2nd March 2011, 14:38   #1
Kazegarou
Junior Member
 
Join Date: Feb 2011
Posts: 4
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:
PHP Code:
inetc::post "C:\Users\Blah\Desktop\test.txt" /FILE /SILENT "http://localhost/PostReceiver.aspx" "$DOCUMENTS\post_reply.htm" /END 
Thanks in advance.
Kazegarou is offline   Reply With Quote
Old 2nd March 2011, 18:45   #2
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Yes, following line sends file to server and puts reply to htm file
code:

inetc:ost "$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...
Takhir is offline   Reply With Quote
Old 2nd March 2011, 21:25   #3
Kazegarou
Junior Member
 
Join Date: Feb 2011
Posts: 4
Hi, Takhir. Thanks for replying

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.
Attached Files
File Type: xml sysLog.xml (649 Bytes, 257 views)
Kazegarou is offline   Reply With Quote
Old 3rd March 2011, 06:59   #4
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
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...
Takhir is offline   Reply With Quote
Old 3rd March 2011, 13:48   #5
Kazegarou
Junior Member
 
Join Date: Feb 2011
Posts: 4
Well, can you attach this post_file.php you wrote? I'd like to compare it to the page I'm using as test.
Kazegarou is offline   Reply With Quote
Old 3rd March 2011, 14:52   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
500 error could mean you have some unhandled exception in your script. Check your phperrors.log file.

Stu
Afrow UK is offline   Reply With Quote
Old 3rd March 2011, 17:42   #7
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
PHP file attached. It is also included to Inetc.zip package http://nsis.sourceforge.net/File:Inetc.zip
Attached Files
File Type: php post_file.php (270 Bytes, 224 views)
Takhir is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
/file, greaterthan, inetc, lessthan, post

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump