What can be the most appropriate answer for this HTTP Problem

  • Thread starter Thread starter 22990atinesh
  • Start date Start date
  • Tags Tags
    Html
Click For Summary

Discussion Overview

The discussion revolves around the HTTP requests and TCP connections involved when a graphical HTML browser accesses a static HTML webpage with an embedded image. Participants explore various scenarios regarding the number of requests and connections required for loading the webpage and the image, considering different interpretations of "embedded" images.

Discussion Character

  • Debate/contested
  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant suggests that only one HTTP request and one TCP connection are necessary, supporting option (C).
  • Another participant argues that the browser must request the image separately after processing the HTML, implying at least two HTTP requests are needed.
  • A different viewpoint proposes that a single GET request could suffice if the image is embedded as a base64 hexadecimal string, eliminating the need for a separate request.
  • Some participants mention using browser developer tools to observe the actual requests made for images, indicating practical methods to verify claims.
  • Another participant discusses the use of local web servers to experiment with HTTP requests and responses, suggesting a hands-on approach to understanding the topic.
  • There is a mention of how browsers handle requests for different types of resources, such as waiting for user interaction for hyperlinks while automatically requesting images.

Areas of Agreement / Disagreement

Participants express differing views on the number of HTTP requests and TCP connections required, with no consensus reached on the correct answer. The discussion remains unresolved regarding the implications of "embedded" images and the behavior of browsers in handling requests.

Contextual Notes

Some participants reference specific browser behaviors and techniques for embedding images, which may depend on the definitions and interpretations of "embedded" in the context of HTTP requests.

22990atinesh
Messages
143
Reaction score
1

Homework Statement


A graphical HTML browser resident at a network client machine Q accesses a static HTML
webpage from a HTTP server S. The static HTML page has exactly one static embedded image
which is also at S. Assuming no caching, which one of the following is correct about the HTML
webpage loading (including the embedded image)?

(A) Q needs to send at least 2 HTTP requests to S, each necessarily in a separate TCP connection to server S
(B) Q needs to send at least 2 HTTP requests to S, but a single TCP connection to server S is sufficient
(C) A single HTTP request from Q to S is sufficient, and a single TCP connection between Q and S is necessary for this
(D) A single HTTP request from Q to S is sufficient, and this is possible without any TCP connection between Q and S

Homework Equations

The Attempt at a Solution


I think only 1 http request and 1 tcp connection is enough. First Q sends an http request to H, then a tcp connection will be established between Q and H. Then H will send an http response having static HTML webpage to Q. Hence (C)
 
Physics news on Phys.org
your client browser having processed the html for display must still request the image too right?
 
jedishrfu said:
your client browser having processed the html for display must still request the image too right?
Since the image is embedded in the html page, my thought (which very well could be wrong) is that a single GET request would suffice without a TCP connection being needed. The payload of the GET request could be broken up into multi-part MIME to represent the text content of the HTML page and the binary portion that is the image.
 
If you're using a browser such as Chrome, you could open the Dev window right now and watch it make the image requests.
 
DaveC426913 said:
If you're using a browser such as Chrome, you could open the Dev window right now and watch it make the image requests.
Chrome, Firefox, IE and possibly other browsers have debugging windows, available by pressing F12. One of the options is to view network traffic, such as HTTP requests and responses.
 
Another way to study this is to install and run a local web server on your own computer. Many people do this under Windows using a WAMP (Windows, Apache, MySQL, PHP) package, or (like me) under Mac OS using a MAMP package. Then you can code a simple test page, call it up in your browser using an address like http://localhost/yourpage.html , and examine the server log file to see exactly which requests it received.
 
Last edited by a moderator:
or you could use node.js to deliver your web page but I think building a web server is overkill for this question. As others have pointed out the debugger feature of most browsers would be sufficient.
 
with respect to the static embedded image I thought it meant that an img tag was used to reference an image as is commonly done.

However, there is a technique to truly embed an image in a webpage using the image tag as a coded base64 hexadecimal string eliminating the request for the image.

The caveat is that people use this trick for small icon images as larger images will make the web page much larger making a request take far longer to download than if you simply downloaded the image in binary. Recall that base64 hexadecimal will use two bytes to represent one binary byte.
 
jedishrfu said:
with respect to the static embedded image I thought it meant that an img tag was used to reference an image as is commonly done.

However, there is a technique to truly embed an image in a webpage using the image tag as a coded base64 hexadecimal string eliminating the request for the image.
This is what I had in mind as being an embedded image.
jedishrfu said:
The caveat is that people use this trick for small icon images as larger images will make the web page much larger making a request take far longer to download than if you simply downloaded the image in binary. Recall that base64 hexadecimal will use two bytes to represent one binary byte.
 
  • #10
Hello jedishrfu, I used Fiddler and it clear my concept. 2 HTTP request and 1 TCP connection will be needed.
One more thing, I want to ask. As Browser sends http request for a webpage, It gets html code in response. It then parse the code and again by default send the http request for the images. But at the same time for some hyperlinks it waits for the client to click on it. For what sort of files browser by default sends http request and for what it does'nt.
 
Last edited:
  • #11
If the html uses the link tag then the web browser will wait until you click on the link. There may be other instances of where things aren't download too.

One, I can think of is javascript code connected to a button or mouse over event that once activated then a request is sent. Another is when a delay timer expires and some javascript code then sends a request. These tricks are often used to bypass web browser protections about opening excessive windows which drive endusers crazy...

http://www.w3schools.com/tags/tag_link.asp

Here's something of interest on Responsive Web Design which talks very briefly about the link tag:

http://en.wikipedia.org/wiki/Responsive_web_design
 

Similar threads

Replies
3
Views
2K
Replies
7
Views
3K
  • · Replies 20 ·
Replies
20
Views
7K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
2
Views
3K
  • · Replies 20 ·
Replies
20
Views
10K
  • · Replies 9 ·
Replies
9
Views
10K
  • · Replies 2 ·
Replies
2
Views
22K