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
The discussion centers on the HTTP requests needed for a graphical HTML browser to load a static webpage with an embedded image. It is established that at least two HTTP requests are necessary: one for the HTML page and another for the embedded image, typically requiring a single TCP connection. Some participants mention that while a single GET request could theoretically suffice if images are embedded as base64 strings, this is impractical for larger images due to increased payload size. The conversation also touches on how browsers handle requests for different types of resources, noting that some requests are made automatically while others depend on user interaction. Overall, the consensus leans towards the need for two requests to effectively load the webpage and its image.
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
6K
  • · Replies 1 ·
Replies
1
Views
7K
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