Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Accessing browsers request

Posted on 1997-12-11
8
Medium Priority
?
186 Views
Last Modified: 2013-12-25
Hi there to all, hope you can help,
I'm writing a C program that needs to know Exactly what the User Typed in ie: a URL or IP number. Tryed environment vars PATH_INFO,& PATH_TRANSLATED, these returned NULL, REQUEST_URI not supported by my web server (Zeus), don't know where to go from here, if anyone can help it would be great.
0
Comment
Question by:Matlock
8 Comments
 
LVL 5

Expert Comment

by:icd
ID: 1831618
The only one that might be of help is REQUEST_URI but this does not include the domain name (or the IP).

Try writing a script that will print all environment variables and see if there is one you can use. (I can give you one in perl but not one in C).

If perl is OK then you can get one at:-

http://www.silkwood.co.uk/cgi-scripts/envir.pl

or run it at

http://www.silkwood.co.uk/cgi-bin/envir.pl

Perhaps it will help you.
0
 
LVL 1

Expert Comment

by:dagmar
ID: 1831619
If you're using perl, you really only need this to see all the environment variables Zeus passes to your CGI...

#!/usr/bin/perl

print "Content-type: text/plain\n\n";

foreach $Key (keys %ENV) {
  print "$Key = :$ENV{$Key}:\n";
}

exit;
0
 
LVL 1

Accepted Solution

by:
tiago earned 400 total points
ID: 1831620
use the environment variable "HTTP_HOST".

example in shell script:

<pre>
#!/bin/sh
echo "Content-type: text/plain"
echo
echo "Host:" $HTTP_HOST
</pre>


example in C:
<pre>
#include <stdio.h>
#include <stdlib.h>

main() {
    printf("Content-type: text/plain\n\n");
    printf("Host:%s\n",getenv("HTTP_HOST"));
}
</pre>
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

Author Comment

by:Matlock
ID: 1831621
I'm unable to grade tiago's answer as perhaps it would seem my question was not correctly phrased, I do not want to know who the Remote Host was  but whether they accessed my site by typing its DNS or by its IP number into their browser, and as unlikely as this may seem, it is actually quite possible for my site.
0
 
LVL 1

Expert Comment

by:tiago
ID: 1831622
"HTTP_HOST" is NOT the remote host!

"HTTP_HOST" provides exactly the information you want:
What host the user has typed in the URL.
0
 

Author Comment

by:Matlock
ID: 1831623
Appologies Tiago,
I misunderstood your response to my Question,
however regretably my server does not support this environment
variable. So I just don't have a clue where to go from here.
Hugh
0
 
LVL 1

Expert Comment

by:tiago
ID: 1831624
Try this (if you have not done it yet):

#!/bin/sh
echo "Content-type: text/plain"
echo
set


and take a look at what environment variables your server uses.
0
 

Author Comment

by:Matlock
ID: 1831625
Tiago, thankyou for your help but it would seem that my Web server doesn't support these environment variables.
I'm out of the office now for over a week so please dont think I'm ignoring any response from you.
Matlock                
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question