How to access HTML headers?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeremy J Starcher

    How to access HTML headers?

    I am developing a script under GreaseMonkey and IE7Pro for a social
    website I am involved with.

    When accessing some pages (user profiles) a 404 error is returned if the
    profile does not exist.

    Fx returns the page to me as given by the server.

    IE7 "helpfully" transforms the simple body contents of "404-Bad Request"
    to something far more elaborate, thus keeping from doing a simple
    contents check.

    I'm looking for a reliable way to detect these 404's. Anyone have advice?
  • Thomas 'PointedEars' Lahn

    #2
    Re: How to access HTML headers?

    Jeremy J Starcher wrote:
    I am developing a script under GreaseMonkey and IE7Pro for a social
    website I am involved with.
    >
    When accessing some pages (user profiles) a 404 error is returned if the
    profile does not exist.
    [...]
    I'm looking for a reliable way to detect these 404's. Anyone have advice?
    IXMLHTTPRequest ::status


    PointedEars
    --
    var bugRiddenCrashP ronePieceOfJunk = (
    navigator.userA gent.indexOf('M SIE 5') != -1
    && navigator.userA gent.indexOf('M ac') != -1
    ) // Plone, register_functi on.js:16

    Comment

    • Jeremy J Starcher

      #3
      Re: How to access HTML headers?

      On Wed, 10 Sep 2008 20:39:45 +0200, Thomas 'PointedEars' Lahn wrote:
      Jeremy J Starcher wrote:
      >I am developing a script under GreaseMonkey and IE7Pro for a social
      >website I am involved with.
      >>
      >When accessing some pages (user profiles) a 404 error is returned if
      >the profile does not exist.
      >[...]
      >I'm looking for a reliable way to detect these 404's. Anyone have
      >advice?
      >
      IXMLHTTPRequest ::status
      >
      >
      PointedEars
      Seems that would do it, but I can't seem to access it from with GM or
      IE7Pro (unless I missed something in my searching.)

      GreaseMonkey runs in a weird space, somewhere below chrome level, yet
      above the page level. It doesn't have access to much more than
      Javascript has, so if there was a standard(ish) Javascript/DOM method,
      that is what I'd need.

      (If document.status existed, that would be the cat's meow, I think.)

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: How to access HTML headers?

        Jeremy J Starcher wrote:
        On Wed, 10 Sep 2008 20:39:45 +0200, Thomas 'PointedEars' Lahn wrote:
        >Jeremy J Starcher wrote:
        >>I am developing a script under GreaseMonkey and IE7Pro for a social
        >>website I am involved with.
        >>>
        >>When accessing some pages (user profiles) a 404 error is returned if
        >>the profile does not exist.
        >>[...]
        >>I'm looking for a reliable way to detect these 404's. Anyone have
        >>advice?
        >IXMLHTTPReques t::status
        >[...]
        >
        Seems that would do it, but I can't seem to access it from with GM or
        IE7Pro (unless I missed something in my searching.)
        Well, since I had never done anything with Greasemonkey, I went to the
        Wikipedia article which lead me to GM's homepage where it says:

        | Thursday, June 12, 2008
        | Greasemonkey Version 0.8
        |
        | [...]
        | Also:
        |
        | * GM_xmlhttpReque st now includes the finalUrl property.

        And then the "Learn to write scripts" quite naturally led to:

        <http://diveintogreasem onkey.org/api/gm_xmlhttpreque st.html>

        where it says:

        | GM_xmlhttpReque st — make an arbitrary HTTP request

        So that looks like a good starting point.
        GreaseMonkey runs in a weird space, somewhere below chrome level, yet
        above the page level. It doesn't have access to much more than
        Javascript has, so if there was a standard(ish) Javascript/DOM method,
        that is what I'd need.
        That is probably why GM provides this object. The GM extension itself runs
        on the chrome level where it can use all kinds of XPCOM Components without
        constraints, including nsIJSXMLHttpReq uest.

        I do not know about IE7Pro, though. (What is it anyway?)


        PointedEars
        --
        Anyone who slaps a 'this page is best viewed with Browser X' label on
        a Web page appears to be yearning for the bad old days, before the Web,
        when you had very little chance of reading a document written on another
        computer, another word processor, or another network. -- Tim Berners-Lee

        Comment

        • Jeremy J Starcher

          #5
          Re: How to access HTML headers?

          On Wed, 10 Sep 2008 21:36:06 +0200, Thomas 'PointedEars' Lahn wrote:
          Jeremy J Starcher wrote:
          >On Wed, 10 Sep 2008 20:39:45 +0200, Thomas 'PointedEars' Lahn wrote:
          >>Jeremy J Starcher wrote:
          >>>I am developing a script under GreaseMonkey and IE7Pro for a social
          >>>website I am involved with.
          >>>>
          >>>When accessing some pages (user profiles) a 404 error is returned if
          >>>the profile does not exist.
          >>>[...]
          >>>I'm looking for a reliable way to detect these 404's. Anyone have
          >>>advice?
          >>IXMLHTTPReque st::status
          >>[...]
          >>
          >Seems that would do it, but I can't seem to access it from with GM or
          >IE7Pro (unless I missed something in my searching.)
          >
          Well, since I had never done anything with Greasemonkey, I went to the
          Wikipedia article which lead me to GM's homepage where it says:
          >
          | Thursday, June 12, 2008
          | Greasemonkey Version 0.8
          |
          | [...]
          | Also:
          |
          | * GM_xmlhttpReque st now includes the finalUrl property.
          >
          And then the "Learn to write scripts" quite naturally led to:
          >
          <http://diveintogreasem onkey.org/api/gm_xmlhttpreque st.html>
          >
          where it says:
          >
          | GM_xmlhttpReque st — make an arbitrary HTTP request
          >
          So that looks like a good starting point.
          *nods* I can do it that way, but it is hackish since it involves
          reloading the current page via GM_xmlhttpReque st.

          I was hoping to find a plain-old-regular Javascript-like-you-would-
          normaly-use-way to do it.

          There might not be one.

          >GreaseMonkey runs in a weird space, somewhere below chrome level, yet
          >above the page level. It doesn't have access to much more than
          >Javascript has, so if there was a standard(ish) Javascript/DOM method,
          >that is what I'd need.
          >
          That is probably why GM provides this object. The GM extension itself
          runs on the chrome level where it can use all kinds of XPCOM Components
          without constraints, including nsIJSXMLHttpReq uest.
          >
          I do not know about IE7Pro, though. (What is it anyway?)
          IE7Pro < http://www.ie7pro.com/ is billed as the "ultimate" extension
          for IE6 and 7 on XP+. Adds user scripts, crash recovery, Mouse Gesture,
          save page as image and a bunch of others.

          There is a shim script that makes IE7Pro work with many GM scripts.
          >
          >
          PointedEars

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: How to access HTML headers?

            Jeremy J Starcher wrote:
            On Wed, 10 Sep 2008 21:36:06 +0200, Thomas 'PointedEars' Lahn wrote:
            >[<http://www.greasespot. net/>]
            >And then the "Learn to write scripts" quite naturally led to:
            >>
            ><http://diveintogreasem onkey.org/api/gm_xmlhttpreque st.html>
            >>
            >where it says:
            >>
            >| GM_xmlhttpReque st — make an arbitrary HTTP request
            >>
            >So that looks like a good starting point.
            >
            *nods* I can do it that way, but it is hackish since it involves
            reloading the current page via GM_xmlhttpReque st.
            >
            I was hoping to find a plain-old-regular Javascript-like-you-would-
            normaly-use-way to do it.
            >
            There might not be one.
            Curious. Why can't you make a HEAD request using the URI of the user
            profile document resource, and navigate there only if that request is
            successful?
            [about IE7Pro <http://www.ie7pro.com/>]
            ACK, thanks.


            PointedEars

            P.S.
            Please trim your quotes to the necessary minimum to retain context and stop
            quoting signatures.
            --
            var bugRiddenCrashP ronePieceOfJunk = (
            navigator.userA gent.indexOf('M SIE 5') != -1
            && navigator.userA gent.indexOf('M ac') != -1
            ) // Plone, register_functi on.js:16

            Comment

            • Jeremy J Starcher

              #7
              Re: How to access HTML headers?

              On Wed, 10 Sep 2008 22:22:31 +0200, Thomas 'PointedEars' Lahn wrote:
              Jeremy J Starcher wrote:
              >*nods* I can do it that way, but it is hackish since it involves
              >reloading the current page via GM_xmlhttpReque st.
              >>
              >I was hoping to find a plain-old-regular Javascript-like-you-would-
              >normaly-use-way to do it.
              >>
              >There might not be one.
              >
              Curious. Why can't you make a HEAD request using the URI of the user
              profile document resource, and navigate there only if that request is
              successful?
              Ah! There is an idea that didn't cross my mind. I've never done just a
              HEAD request, but if it works, that will be a better route to take.
              Thanks.

              I'll run some tests tonight.
              P.S.
              Please trim your quotes to the necessary minimum to retain context and
              stop quoting signatures.
              ACK. I'll kick myself in the seat of my pants to remind me.

              Comment

              • Michael Wojcik

                #8
                Re: How to access HTML headers?

                You've already received what looks like good advice from Thomas (XHR a
                HEAD request and check the status) for this problem, but I wanted to
                make a quick comment on your subject line. The information you're
                looking for is neither a header nor anything to do with HTML; it's the
                HTTP Status-Code. (See RFC 2616.)

                I mention this only because the wrong nomenclature could be confusing
                for maintainers.

                --
                Michael Wojcik
                Micro Focus
                Rhetoric & Writing, Michigan State University

                Comment

                • Jeremy J Starcher

                  #9
                  Re: How to access HTML headers?

                  On Thu, 11 Sep 2008 14:14:53 -0400, Michael Wojcik wrote:
                  You've already received what looks like good advice from Thomas (XHR a
                  HEAD request and check the status) for this problem, but I wanted to
                  make a quick comment on your subject line. The information you're
                  looking for is neither a header nor anything to do with HTML; it's the
                  HTTP Status-Code. (See RFC 2616.)
                  Correction accepted.


                  Comment

                  Working...