How to get CGI request-URL

Discussion in 'Python' started by Hallvard B Furuseth, Jul 4, 2003.

  1. How can I get the URL the user typed (except the part after '?') with
    the cgi module?

    I expect the 'Host:' HTTP header + os.environ['SCRIPT_NAME'] would do
    it, but I don't see how to find the Host header. The www server has
    several names, so I can't just use the default host name.

    --
    Hallvard
     
    Hallvard B Furuseth, Jul 4, 2003
    #1
    1. Advertising

  2. Hallvard B Furuseth

    Peter Hansen Guest

    Hallvard B Furuseth wrote:
    >
    > How can I get the URL the user typed (except the part after '?') with
    > the cgi module?
    >
    > I expect the 'Host:' HTTP header + os.environ['SCRIPT_NAME'] would do
    > it, but I don't see how to find the Host header. The www server has
    > several names, so I can't just use the default host name.


    This might help: http://hoohoo.ncsa.uiuc.edu/cgi/env.html

    Found via Google....
     
    Peter Hansen, Jul 4, 2003
    #2
    1. Advertising

  3. "Hallvard B Furuseth" <h.b.furuseth(nospam)@usit.uio(nospam).no> a écrit
    dans le message de news: ...
    > How can I get the URL the user typed (except the part after '?') with
    > the cgi module?
    >
    > I expect the 'Host:' HTTP header + os.environ['SCRIPT_NAME'] would do
    > it, but I don't see how to find the Host header. The www server has
    > several names, so I can't just use the default host name.
    >
    > --
    > Hallvard


    Don't remember but...

    There's a test() function in the cgi module that shows the special data
    available from a CGI script.

    --Gilles
     
    Gilles Lenfant, Jul 4, 2003
    #3
  4. Hallvard B Furuseth wrote:
    > Thanks for the answers.
    >


    Glad to be of assistance, but you didn't tell us what the
    actual solution to your problem was... It is always a good idea
    to do so because others that have the same problem, and
    reading the thread, can immediately benefit :)

    --Irmen
     
    Irmen de Jong, Jul 5, 2003
    #4
  5. Irmen de Jong wrote:
    > Glad to be of assistance, but you didn't tell us what the
    > actual solution to your problem was... It is always a good idea
    > to do so because others that have the same problem, and
    > reading the thread, can immediately benefit :)


    Good point. I'll come back when I'm sure my solution actually works...
    I need to get someone to intall the program first.

    --
    Hallvard
     
    Hallvard B Furuseth, Jul 5, 2003
    #5
  6. Irmen de Jong wrote:

    > Glad to be of assistance, but you didn't tell us what the
    > actual solution to your problem was...


    'https://' + os.environ['SERVER_NAME'] + os.environ['REQUEST_URI']

    --
    Hallvard
     
    Hallvard B Furuseth, Jul 18, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Birtle
    Replies:
    2
    Views:
    2,102
    John Saunders
    Oct 16, 2003
  2. Replies:
    1
    Views:
    6,309
    Ryan Stewart
    Dec 29, 2004
  3. =?Utf-8?B?QXhlbCBEYWhtZW4=?=

    Malformed URL by using Page.Request.Url.ToString() - why?

    =?Utf-8?B?QXhlbCBEYWhtZW4=?=, Apr 17, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    901
    Walter Wang [MSFT]
    Apr 18, 2007
  4. Íßêïò
    Replies:
    1
    Views:
    458
    Jason Friedman
    Jul 21, 2010
  5. mews.microsoft.com
    Replies:
    0
    Views:
    251
    mews.microsoft.com
    Mar 2, 2005
Loading...

Share This Page