We launched a new IT training category! Check out the 140+ courses now.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

How CGI works

From: CGI Essential Training

Video: How CGI works

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.

How CGI works

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.

Show transcript

This video is part of

Image for CGI Essential Training
CGI Essential Training

23 video lessons · 7900 viewers

Bill Weinman
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed CGI Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.