Solved

Accessing browsers request

Posted on 1997-12-11
8
144 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 200 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
 

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now