HTTP Demo

Share Tips, Code Samples, etc. with the Visual Prolog community.
Post Reply
Chan Bok
Active Member
Posts: 69
Joined: 13 Sep 2000 23:01

HTTP Demo

Post by Chan Bok » 8 Jun 2010 15:33

This demo uses WinInet (HTTP) to transfer data between client and server.
The demo is developed on VIP7.2 (CE). To compile, you need to include wininet.lib

The demo essentially simulates the following HTML form:

Code: Select all

  <form enctype="multipart/form-data" action="myphp.php" method="POST">    Fields:          <input type="text" name="fields" /><br />            <input type="submit" value="Send!" />    </form>
The httpPost() function has also been extended to perform file upload/download/chat
in the Axon Idea Processor (currently Axon2011 R1.10 Beta).
These additional features are omited to avoid complicating the demo.

You may copy and use this demo for any purpose, commercial or otherwise.

Chan Bok
Axon Research
Attachments
httpDemo.zip
(29.19 KiB) Downloaded 913 times
Chan Bok
Axon Research

Timmy
Posts: 7
Joined: 10 Aug 2010 13:52

Post by Timmy » 11 Aug 2010 16:49

Hi, I'm using VIP 7.2 CE and I can't use this demo because of some troubles with wininet.lib, but I guess I don't need it, because the same thing on VIP 5x was ok with using just httplay. So here is the problem. I always get only httplay_error for any requests. Here is sample code (I use other URL in my project):

Code: Select all

onPushButtonClick(_Source) = button::defaultAction:-         httplay::httplay_sendrequests(                                                     This:getVpiWindow(),                                                     12345,                                                                                                 "http://discuss.visual-prolog.com",                                                     80,                                                     [httplay::simple_req(httplay::rel_path("http://discuss.visual-prolog.com/viewforum.php?",[],"f=2"))],                                                     1).

Code: Select all

onPushButton1Click(_Source) = button::defaultAction:-                 try         httplay::httplay_GetAnswer(Answer),         stdio::write(Answer)         catch _ do         stdio::write("EXCEPTION\n")         finally         stdio::write("END\n")         end try,         !.     onPushButton1Click(_Source) = button::defaultAction.
The result is

Code: Select all

httplay_error(simple_req(rel_path("http://discuss.visual-prolog.com/viewforum.php?",[],"f=2")),traceinfo([lineinfo("D:\\visual prolog 7.2\\pfc\\exception\\exception.pro",187),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\VIP7Kernel.dll",335583316),lineinfo("D:\\visual prolog 7.2\\pfc\\exception\\exception.pro",187),lineinfo("D:\\visual prolog 7.2\\pfc\\5xVIP\\sockbind\\msgLayerAsync\\msgLayerAsync.pro",235),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\VIP7Kernel.dll",335584085),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\vip7vpi.dll",355603857),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\vip7vpi.dll",355554599),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\vip7vpi.dll",355560525),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\vip7vpi.dll",355589556),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\vip7vpi.dll",355597247),addressinfo("C:\\WINDOWS\\system32\\USER32.dll",2117502772),addressinfo("C:\\WINDOWS\\system32\\USER32.dll",2117549284),addressinfo("C:\\WINDOWS\\system32\\USER32.dll",2117548848),addressinfo("C:\\WINDOWS\\system32\\USER32.dll",2117549404),addressinfo("C:\\WINDOWS\\system32\\USER32.dll",2117502772),addressinfo("C:\\WINDOWS\\system32\\USER32.dll",2117502998),addressinfo("C:\\WINDOWS\\system32\\USER32.dll",2117503437),addressinfo("C:\\WINDOWS\\system32\\USER32.dll",2117503504),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\vip7vpi.dll",355584137),lineinfo("D:\\visual prolog 7.2\\pfc\\vpi\\vpi.pro",270),lineinfo("D:\\visual prolog 7.2\\pfc\\application\\exe\\mainExe.pro",28),lineinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\main.pro",24),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\VIP7Kernel.dll",335583497),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\asd.exe",4959820),lineinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\main.pro",24),addressinfo("C:\\WINDOWS\\system32\\kernel32.dll",2088857719),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\asd.exe",54394898),addressinfo("",2147303424),addressinfo("C:\\WINDOWS\\system32\\kernel32.dll",2088999640),addressinfo("C:\\WINDOWS\\system32\\kernel32.dll",2088857728),addressinfo("C:\\Documents and Settings\\Marina\\&#1052;&#1086;&#1080; &#1076;&#1086;&#1082;&#1091;&#1084;&#1077;&#1085;&#1090;&#1099;\\Visual Prolog Projects\\asd\\Exe\\asd.exe",4959760)],[descriptor(classinfodescriptor("5xVIP/sockbind/msglayer/msgLayerAsync","Version 1.0"),exceptiondescriptor(classinfodescriptor("com/visual-prolog/5xVip/sockbind/sockbind","Version 1.1"),"exceptionSckGeneral","A general socket exception"),raised(),[namedvalue("socket_error_code",integer(11004))],129260183841093750,"A general socket exception",2840)],"Microsoft Windows XP OS version not supported or bad data. Service Pack 3 (Build 2600)\nNumber Of Processors: 1  PageSize: 4096  Processor: 586 level: 15 revision: 516\nProcessorNameString:               Intel(R) Pentium(R) 4 CPU 2.00GHz\nVendorIdentifier: GenuineIntel\nIdentifier: x86 Family 15 Model 2 Stepping 4\n~MHz: 1997"))
What am I doing wrong?
Besides, is there any book with all the information about all classes, packages etc? I've got dozens of questions about threads, sockets, graphics etc and all the answers i can get is some code from installed examples,
thanks.

drspro2
Active Member
Posts: 111
Joined: 28 Apr 2006 12:03

Post by drspro2 » 12 Aug 2010 12:00

in the tools section there is an example of Gildas wich fetches pictures from the internet url,

maybe u can use that project ,


that project succesfully gets url content

Timmy
Posts: 7
Joined: 10 Aug 2010 13:52

Post by Timmy » 12 Aug 2010 13:23

I can get the URL content to file using URLDownloadtoFile from urlmon.lib, but I want to have it in memory

Timmy
Posts: 7
Joined: 10 Aug 2010 13:52

Post by Timmy » 13 Aug 2010 9:24

Done it using wininet.dll, thanks

Post Reply