How to get CGI request-URL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hallvard B Furuseth

    How to get CGI request-URL

    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
  • Peter Hansen

    #2
    Re: How to get CGI request-URL

    Hallvard B Furuseth wrote:[color=blue]
    >
    > 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.[/color]

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

    Found via Google....

    Comment

    • Gilles Lenfant

      #3
      Re: How to get CGI request-URL

      "Hallvard B Furuseth" <h.b.furuseth(n ospam)@usit.uio (nospam).no> a écrit
      dans le message de news: HBF.20030704ty6 d@bombur.uio.no...[color=blue]
      > 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[/color]

      Don't remember but...

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

      --Gilles

      Comment

      • Irmen de Jong

        #4
        Re: How to get CGI request-URL

        Hallvard B Furuseth wrote:[color=blue]
        > Thanks for the answers.
        >[/color]

        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

        Comment

        • Hallvard B Furuseth

          #5
          Re: How to get CGI request-URL

          Irmen de Jong wrote:[color=blue]
          > 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 :-)[/color]

          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

          Comment

          • Hallvard B Furuseth

            #6
            Re: How to get CGI request-URL

            Irmen de Jong wrote:
            [color=blue]
            > Glad to be of assistance, but you didn't tell us what the
            > actual solution to your problem was...[/color]

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

            --
            Hallvard

            Comment

            Working...