You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Vinod Mehra <vi...@beasys.com> on 1999/11/12 01:18:57 UTC

Resolving ebmedded image references in an HTML page

Hi,

I have an apache module which gets an html page from somewhere upon a
request from the client
and then passes it back to the client.  The image references are not
getting resolved.

eg. my request is like:
    GET <my-tag>/acommand HTTP/1.1
This returns an html page with an image refernce : for
/servletimages/trans.gif

It logs error messages like: file doesn't exist - pointing to the local
file system.
    File does not exist: c:/program files/apache
group/apache/htdocs/servletimages/trans.gif

The corresponsing request it logs into access.log is :
    GET /servletimages/trans.gif HTTP/1.1

I was expecting the request to be : 
    GET /<my-tag>/servletimages/trans.gif HTTP/1.1

How to change this behaviour. Same logic works for NSAPI/ISAPI.

This is my how my code looks like when I send a html file with embedded
image references back 
to the client:

    set the r->header_out ...
    r->content_type = "some appropriate value; eg image/gif or image/jpeg";
    ap_send_http_header(r);
    char buf[BUF_SIZE];
    int x = 0;
    while ((x = uref->read(buf, BUF_SIZE)) > 0)
    {
	buf[x]='\0';
	ap_rwrite(buf, x, r);
	memset(buf, 0, BUF_SIZE);
    }

What am I missing here?

Thanks in advance,
Vinod. 

Re: Resolving ebmedded image references in an HTML page

Posted by Manoj Kasichainula <ma...@io.com>.
Heavy snippage
On Thu, Nov 11, 1999 at 04:18:57PM -0800, Vinod Mehra wrote:
>
> eg. my request is like:
>     GET <my-tag>/acommand HTTP/1.1
> This returns an html page with an image refernce : for
> /servletimages/trans.gif
> 
> The corresponsing request it logs into access.log is :
>     GET /servletimages/trans.gif HTTP/1.1
> 
> I was expecting the request to be : 
>     GET /<my-tag>/servletimages/trans.gif HTTP/1.1

If the HTML you send back refers to "/servletimages/trans.gif", then
the browser will ask for "/servletimages/trans.gif". If you want it to
ask for "/<my-tag>/servletimages/trans.gif", then you should either
use "/<my-tag>/servletimages/trans.gif", or use a relative reference:
"servletimages/trans.gif" without the leading slash.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/
"We can't protect the idiot." - David Vance of Glaxo Wellcome

Re: Resolving ebmedded image references in an HTML page

Posted by Manoj Kasichainula <ma...@io.com>.
On Thu, Nov 11, 1999 at 04:52:32PM -0800, Vinod Mehra wrote:
> I am sorry that was a typo.
> 
> The image reference is servletimages/trans.gif without
> the leading"/".
> 
> img src=servletimages/trans.gif

You do have quotes around servletimages/trans.gif, right?

Have you checked that the client is indeed receiving the image URLs
correctly? If so, then this can't be Apache's problem. The browser's
conception of the base URL for your document is probably not correct.

BTW, I noticed something else very strange:

> This is my how my code looks like when I send a html file with embedded
> image references back
> to the client:
> 
>     set the r->header_out ...
>     r->content_type = "some appropriate value; eg image/gif or image/jpeg";

You're not actually setting the content type of the HTML to image/*,
right? I think IE will let you get away with that error, but I could
see it not setting its conception of base URL correctly if it gets the
wrong MIME type.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/

Re: Resolving ebmedded image references in an HTML page

Posted by Vinod Mehra <vi...@beasys.com>.
I am sorry that was a typo.

The image reference is servletimages/trans.gif without
the leading"/".

img src=servletimages/trans.gif

Sorry about that. So the problem still remains open.

Vinod.


At 04:34 PM 11/11/99 -0800, Greg Stein wrote:
>On Thu, 11 Nov 1999, Vinod Mehra wrote:
>> and then passes it back to the client.  The image references are not
>> getting resolved.
>> 
>> eg. my request is like:
>>     GET <my-tag>/acommand HTTP/1.1
>> This returns an html page with an image refernce : for
>> /servletimages/trans.gif
>
>Is that the actual reference? With a leading "/" on it?
>
>If so, then that is how the web works! It means the reference is relative
>to the server, rather than the request-URI. Drop the leading "/" and the
>web browser should construct the final request properly.
>
>I'd recommend reading up on "relative URIs (URLs)" and "absolute URIs
>(URLs)" somewhere. No references right now, but any basic authoring book
>should discuss them.
>
>However, if you typoed and that leading "/" is *not* there, then I dunno.
>Your code looks fine.
>
>Cheers,
>-g
>
>--
>Greg Stein, http://www.lyra.org/
> 

Re: Resolving ebmedded image references in an HTML page

Posted by Greg Stein <gs...@lyra.org>.
Note: please use apache-modules for questions like this. Also, you had
already sent this message without a subject line. Adding one and
*resending* simply means that everybody gets spammed with multiple copies.
Not to mention one copy for new-httpd and one for apache-modules.

Now... to the question...

On Thu, 11 Nov 1999, Vinod Mehra wrote:
> and then passes it back to the client.  The image references are not
> getting resolved.
> 
> eg. my request is like:
>     GET <my-tag>/acommand HTTP/1.1
> This returns an html page with an image refernce : for
> /servletimages/trans.gif

Is that the actual reference? With a leading "/" on it?

If so, then that is how the web works! It means the reference is relative
to the server, rather than the request-URI. Drop the leading "/" and the
web browser should construct the final request properly.

I'd recommend reading up on "relative URIs (URLs)" and "absolute URIs
(URLs)" somewhere. No references right now, but any basic authoring book
should discuss them.

However, if you typoed and that leading "/" is *not* there, then I dunno.
Your code looks fine.

Cheers,
-g

--
Greg Stein, http://www.lyra.org/