How to check application version with HTTP GET?

Started by
10 comments, last by floatingwoods 9 years, 1 month ago

Hello,

what is the simplest method to check if there is a new program version available?

I have my application, a server, and also a website. The application is c++.

How to send an http GET command, and how to serve it?

My idea was to simply have a text file on my website that contains a string (e.g. "version1.2.1"), and to retrieve it with GET. How to go about that, without having to add numerous includes and libraries to my application?

Thanks

Advertisement

How to go about that, without having to add numerous includes and libraries to my application?


Do you eat spaghetti with your bare hands? Without any libraries at all, you will have to write an operating system and drivers for your hardware from scratch. Could be fun. Or you could use a library instead and get it done easier.

At the very least, you can use sockets to implement a minimal subset of HTTP yourself. But if you're going to do that, why bother using HTTP at all? Just use plain old TCP, write a client and server, and send some bytes back and forth.
libcurl is a pretty popular library for this stuff.

Microsoft's cross-platform REST toolkit is also pretty darn rad. Boost's libraries have some utilities for this. libevent has a small HTTP server and (I think) client.

Sean Middleditch – Game Systems Engineer – Join my team!

Opening a socket connection to a server and sending a HTTP 1.0 style request is not too bad. You can send a byte string for the request and read data from the socket. As long as everything works ideally and you get a 200-OK response from the server, you can do it in around 30 lines of code. Like this.

But HTTP is a fairly big protocol. Lots of things can go wrong. The server can ask you to delay with a Continue message, or redirect you temporarily or permanently, or ask you to retry, or have various other responses. Consequently it is usually best to use a library that handles the various conditions that HTTP can present.

You could just stash your installer in a Web server and use a http HEAD request to check the last modified date and see if it's newer than the modification date of your own executable from the win32 VERSIONINFO resource.

This is relatively easy to do with any HTTP library, you could then direct the user to the website if you don't want to spend time writing a downloader...

+1 for libcurl

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532


Microsoft's cross-platform REST toolkit is also pretty darn rad.

What is the name of this?

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

The name is Microsoft's C++ REST SDK

That is a terrible name. dry.png

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

The code name was "Casablanca". Given the choice between "white house" and "C++ REST SDK", I prefer the one with a descriptive name.

There are so many products out there ("hadoop", "heroku", "jasmine", "komida", ...) where the fanciful names don't give any clue to what the product does.

This topic is closed to new replies.

Advertisement