Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
So let's talk about how CGI works. When your browser goes to get a webpage, you type in the address in your address bar and you press Go or you hit Enter on your keyboard. The browser sends a request to the server using the HTTP Protocol. HTTP, besides being a bit of a tongue twister, stands for Hyper Text Transfer Protocol. What that is, is that's the protocol that the browser uses to communicate with the server and that the server uses to communicate back with the browser.
So for example, I am going to show you an HTTP transaction here and this is using a tool that I wrote years ago that I call Web Tool and it is just easy way for me to look at that communication that's going on between the browser and the server. And so the tool itself, it pretends that it's a browser and it sends a request to the server, and that request looks like this here. And so, in this case, this is one of my servers. It's the one that hosts images for my website. I call it i.bw.org.
And so I am running this tool on my server. I am going to include a copy of this tool in the Exercise Files so that you can install it on your server. I ask that you do not run it on my server and that's why I am hiding the address here. But this is something if you are interested in this level of detail. It's not really required in order to write CGI applications. But if you are interested in this level of detail, this is a tool that might be useful to you. And so, this is what the transaction looks like. The browser sends this request and then the server responds with all of the rest of this.
The top part of this is the header that the server sends back and identifies the protocol. It gives the date and some other information and we will talk about those details in a while. Those are actually exposed to the CGI application so you will see those and then it passes back whatever the webpage looks like. In this case, this is just some HTML. This is just a blank page and actually this page looks like this. This page intentionally left blank. That's just a blank page like on the front of it.
It's just a small piece of HTML. So this is what the actual transaction looks like when it's just the browser talking to the server. When you are using a CGI application and the browser sends the request to the server, the server then before responding back to the browser, before sending that header and the webpage back to the browser, it sends the information onto the CGI application, and it waits for the CGI application to respond. The way that it sends the information to the CGI application is very different, because it's not communicating over the Internet, so it is not sending a stream of information that includes headers and the body and things like that.
Instead, it communicates the way that programs communicate with each other on a computer. It sends environment variables to the CGI application and if there is a body that it needs to send, it will send that in what's called the Standard Instream out to the application. Then the CGI application responds back to the server and the server sends that response back to the web browser in the same way that we saw over there. So that's in a nutshell how CGI works.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 92480 Viewers
82 Video lessons · 104137 Viewers
71 Video lessons · 75610 Viewers
56 Video lessons · 106983 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.