|Subject:||Re: Browser image requests - no path Info in GET|
|Posted by:||Remy Lebeau (Indy Team) (firstname.lastname@example.org)|
|Date:||Fri, 29 Sep 2006|
"tony meadors" <tonymeado…@adelphia.net> wrote in message
> In response to a POST request (providing values) my INDY
> server returns an HTML file with sendfile(). That file arrives fine,
> but the followup image requests made by the browser are
> always filename only, no path, so they are not grabbed.
Your understanding of how HTTP actually works is a little lacking. You are
not taking into account that the browser has no concept whatsoever of your
file system hierarchy actualy is on the server. Paths specified in the HTML
are URLs, not physical file system folders. Depending on what the actual
HTML looks like, the browser is trying to load the image from the same URL
folder that the HTML file was requested from. That has nothing to do with
your file system paths. Resource paths in HTTP requests are always
specified as URLs relative to the server's root folder ("/"), never as file
Let me give you an example. Assume a browser loads a page at
http://www.myserver.com/page.html", and the HTML contains an image "<img
src=image.jpg>". Since there is no '/' in the front of the URL of the
image, the actual location of the image is relative to the URL of the HTML
page. In this case, the full URL to the image is
http://www.myserver.com/image.jpg" when expanded by the browser. That
results in a "GET /image.jpg" request.
It is your server code's responsibility to determine what physical folder
relates to the URL's '/' root folder, and then apply the rest of the URL to
that physical folder. So if your root folder is at
"C:\root\genfiles\temp\777", then a URL of "/image.jpg" would serve up
> For example, this call:
> Generates the following image call by the browser is:
> GET \headerlogo.jpg
What does the actual HTML look like? What URL is the browser actually using
to access report67.htm?
Chances are, the page is being loaded via a URL that specifies the HTML file
is in the server's root folder, and the HTML contains a relative URL for the
image, so the browser requests the image from the same root folder that the
HTML file is requested from. Or else the HTML file is not in the root
folder, but the HTML contains an image URL that begins with "/", so the
browser is forced to load the image from the server's root folder.
> What I would like to get from the browser is obvious:
> GET \root\genfiles\temp\777\headerlogo.jpg
For that to work, the URL of the HTML file would have to be
http://www.server.com/root/genfiles/temp/777/page.html", or if the HTML
contains an image URL of "/root/genfiles/temp/777/headerlogo.jpg".
> The image(s) are located down in the 777 directory, not in the root.
From the perspective of your file system, that is correct. But not from the
perspective of the URLs that are involved. All URLs for the erver are
relative to the server's "/" root folder. Where the "/" actually points to
on your file system, that is up to your own code to manage.
> How can I have GET image references use either,
> the same directory stem as the original htm file
By learning how HTTP and URLs actually work, and then update your code to
use them properly. To load an image from the same folder as the HTML file,
the HTML has simply to specify the image filename with no path, and the
browser will expand the filename into a full URL accordingly. When a
request is made to the server, the request always contains a full path
starting at the "/" root folder, in terms of HTTP paths, not in terms of
file system paths. You have to translate between the two in your code.
> Possibly by setting values in requestinfo or responseinfo??
Browser image requests - no path Info in GET posted by tony meadors on Fri, 29 Sep 2006