PDA

View Full Version : Retrieving A File From The Internet


PointOfLight
11-14-2008, 05:29 AM
It has been way too long since I've posted here. Not only that, but I decided to be annoying with this post. But, it's late and I need to go to bed so I don't fall asleep at work. Anyway, I had an offline request from someone on how to retrieve a file using HTTP GET. I know a while back I had been working on one for posting a file (with questionable success), but I took that code and started playing around with the GET command instead, and low and behold I finally got it to work!

What this all boils down to is that tomorrow night after work, once I've had a chance to clean it up a bit, I will be posting the code so you can all bask in it's wondrousness (okay, it's probably really not all that great, but at least it works). And, with any luck maybe now I can figure out how to get the posting to work as well.

Thanks for humoring me, sorry, for the ridiculous post, and we'll see you tomorrow night...

kornalius
11-14-2008, 04:10 PM
Nice to see you back Eric. I hope you will stay around for some time. :) We kinda miss you here.

Thanks for the "future" code submission.

PointOfLight
11-14-2008, 06:33 PM
I really miss being here, though actually I've never truly left. The reality is that I just haven't had the time lately to do much extraneous programming, and when I've had the freem time I've chosen to veg a bit instead. I still watch the forums frequently, I just do it fairly silently. Hopefully I'll be able to get back into the game soon.

zehlein
11-15-2008, 11:45 AM
... and when I've had the freem time I've chosen to veg a bit instead. ...

:confused:Eric, just for the non-native speakers: what do you do when you veg a bit!? :confused:

kornalius
11-15-2008, 03:16 PM
It means, relaxing on the couch, not doing anything in particular and not thinking about anything! :)

PointOfLight
11-15-2008, 04:54 PM
Sorry, Zehlein. I was afraid that phrase might be a bit weird, but I was being too lazy to put it any other way. However, Alain was right in his interpretation. Anyway, on to the important stuff. Here's the sample I promised: http://www.csdatasol.net/Downloads/http_file.ppl It's documented, but feel free to ask questions anyway, and I'll do my best to answer them. This is only the read file portion of the code, however. I didn't have time to look into the writing portion yet to see if I could fix it. I will tackle that some other time.

[Edit]

Turns out I actually left the login information to my server in the last version of this code that I posted, so I had to pull it temporarily. I placed a new version out there that has both read and write code in it. There are two WinMain functions, one to demonstrate reading a file and the other for writing it. Unfortunately, the write portion of the code still doesn't work. The odd thing, however, is that all the Internet functions that get called either return the appropriate handles or True, indicating that everything is working fine. Yet when I check on the server no file was written. If someone is able to figure this out, please let us know. Thanks.

Alco
11-21-2008, 03:03 PM
Hello All,

I am the "offline request" that Eric talks about.

Eric's code has been very helpful. I was able to do exactly what I needed, which was to get the Raw HTML code out of an HTTP GET request. Now, I have not been able to make it work on my phone using the carrier's (Sprint) internet connection. Eric tells me that it works over is own phone's wifi connection. He also points out that there may be differences in how the winsock calls are made. Does anyone has any comments or suggestions?

Thank you all,

-R