Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / http connect / http send request

Author
Message
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 9th Jul 2010 06:10
hey all

I've got some questions about these commands.

It appears to be utilizing wininet, which I found documentation for here:
http://msdn.microsoft.com/en-us/library/aa385483(v=VS.85).aspx

When I attempt to run http send request, I got an error. I determined the error is because I don't have a trusted certificate for the secure site I'm accessing. It appears I cannot connect to a standard http site (must be https)

Is there a way I can set this so I can send requests via standard http? I'm getting by right now by having added my server as a trusted certificate authority, but I don't think this'll fly in the final product. I don't want to buy a certificate because it's unnecessary for my application, and it's a drain on server resources to have encrypted connections.

Thanks for any insight!

bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 10th Jul 2010 06:03
Anybody got any ideas? Is there some wierd windows calls I can make that'll take care of this? Any alternate plugins that do the same things as these commands?

Thanks!

GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 10th Jul 2010 07:15 Edited at: 10th Jul 2010 07:15
What are you trying to do?

I recently wrote some non-blocking code to download files via HTTP. I used this snippet as an example:



Source

bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 10th Jul 2010 09:57 Edited at: 10th Jul 2010 09:58
I'm making a call to a PHP page which will output an XML file (in UTF-8 format) based on the parameters passed to the URL.

The DBP built in functions (http connect / http send request) work perfectly except that they require a secure connection using a trusted Certificate Authority issued SSL certificate.

Is there a way I could have dbp remove this requirement, or would I have to re-create the DBP built in functions manually like you have done?

bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 10th Jul 2010 10:12 Edited at: 10th Jul 2010 10:46
I see this has already been addressed by TGC in update 7.2:

Update Notes:
Quote: "HTTP CONNECT has additional parameter to specify port number (80=HTTP/443=HTTPS)"


It either was undocumented in the help or I haven't updated that far yet. (Won't know till I can hop on my home computer).

Thanks anyway!

Hockeykid
DBPro Tool Maker
16
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jul 2010 10:16 Edited at: 10th Jul 2010 10:17
This should do the trick.



The from$ field should be the website's URL (along with any php extensions) and the to$ field should be the file you want to retrieve the website's output.

Example:

download("http://highscore.mygamesonline.org/dbpost.php?n=myname&s=100","C:\highscore.txt")

bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 10th Jul 2010 10:48 Edited at: 10th Jul 2010 10:50
Hmm, that's interesting. That'll allow me to output to a file, whereas DBP commands I can only download to a variable, as far as I can tell.

Super handy, much thanks!

bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 12th Jul 2010 15:52


This code works wonderfully, except it caches the results. I've tried this code:



Per the following links:
http://support.microsoft.com/kb/q196466/en-us (shows how to use the constant flag)
http://msdn.microsoft.com/en-us/library/ms775130%28VS.85%29.aspx (shows the constant's value)

I've tried putting the value right into the dll call too and no change. Any ideas what's wrong?

bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 13th Jul 2010 04:54 Edited at: 13th Jul 2010 04:55
Alright! Found an answer to the issue here that actually works:

http://stackoverflow.com/questions/75432/how-can-i-prevent-urldownloadtofile-from-retrieving-from-the-cache

Here's the code. If the cache file exists, it will be deleted before it's redownloaded.



Login to post a reply

Server time is: 2024-04-23 15:19:55
Your offset time is: 2024-04-23 15:19:55