Loading ...
Sorry, an error occurred while loading the content.

POSTING to a URI that contains a query string ?

Expand Messages
  • Jan Algermissen
    Hi, this might actually be an FAQ question, but I want to make sure not just legal HTTP but also RESTful: Can I POST to a URI that contains a query string ?
    Message 1 of 8 , Oct 10, 2002
    • 0 Attachment
      Hi,

      this might actually be an FAQ question, but I want to make
      sure not just 'legal HTTP' but also RESTful:

      Can I POST to a URI that contains a query string ?

      Example (adding a link to a linklist) :

      POST /linklist?subject=travel HTTP/1.0
      Host: www.myhost.com
      Content-Length: 28

      http://www.cheaptravel.com

      Would this be OK ?



      Would it be OK in an HTML <form action="..." method="POST">
      element to specify an action URL that contains a query string ?


      Jan




      --
      Jan Algermissen
      Consultant & Programmer

      Tel: ++49 (0)40 89 700 511
      ++49 (0)177 283 1440
      Fax: ++49 (0)40 89 700 841
      Email: algermissen@...
      Web: http://www.topicmapping.com
    • Chris Croome
      Hi ... We haven t had any luck doing that with Apache and Perl, the result is always the same as posting without the query string. Populating the form with the
      Message 2 of 8 , Oct 10, 2002
      • 0 Attachment
        Hi

        On Thu 10-Oct-2002 at 07:09:02PM +0200, Jan Algermissen wrote:
        >
        > Can I POST to a URI that contains a query string ?

        We haven't had any luck doing that with Apache and Perl, the result
        is always the same as posting without the query string.

        Populating the form with the information from the query string
        seems the most logical thing to do.

        Chris

        --
        Chris Croome <chris@...>
        web design http://www.webarchitects.co.uk/
        web content management http://mkdoc.com/
        everything else http://chris.croome.net/
      • S. Mike Dierken
        ... From: Jan Algermissen ... Absolutely. ... Definitely. ... Yes. The only caution I would have is when server tools parse the
        Message 3 of 8 , Oct 10, 2002
        • 0 Attachment
          ----- Original Message -----
          From: "Jan Algermissen" <algermissen@...>

          > Can I POST to a URI that contains a query string ?
          Absolutely.

          >
          > Example (adding a link to a linklist) :
          >
          > POST /linklist?subject=travel HTTP/1.0
          > Host: www.myhost.com
          > Content-Length: 28
          >
          > http://www.cheaptravel.com
          >
          > Would this be OK ?
          Definitely.

          >
          >
          >
          > Would it be OK in an HTML <form action="..." method="POST">
          > element to specify an action URL that contains a query string ?
          Yes.

          The only caution I would have is when server tools parse the request, they
          don't always do it right. Often they provide a request property called
          'parameters' - but there is no such thing in the protocol. This usually is a
          blending of the query terms from the resource identifier and the name/value
          pairs from the content being posted. Another example where common tools are
          broken with respect to using the protocol correctly.
          Often, you will have to explicitly get the query terms separate from the
          form data. I think ASP pages can do this relatively easily. If the names
          between query terms and content body are the same you may have problems, so
          I'd recommend avoiding that.

          Mike
        • Vincent D Murphy
          [yahoo groups was bouncing my mail, so i m reposting this.] On Thursday, Oct 10, 2002, at 21:24 Europe/Dublin, S. Mike Dierken ... agreed. in perl, pretty
          Message 4 of 8 , Oct 10, 2002
          • 0 Attachment
            [yahoo groups was bouncing my mail, so i'm reposting this.]

            On Thursday, Oct 10, 2002, at 21:24 Europe/Dublin, S. Mike Dierken
            wrote:
            > The only caution I would have is when server tools parse the request,
            > they
            > don't always do it right. Often they provide a request property called
            > 'parameters' - but there is no such thing in the protocol. This
            > usually is a
            > blending of the query terms from the resource identifier and the
            > name/value
            > pairs from the content being posted. Another example where common
            > tools are
            > broken with respect to using the protocol correctly.

            agreed. in perl, pretty much all of the CPAN CGI modules (including
            the erst-while CPAN.pm) advertise this breakage as a feature (although
            to be fair i guess not many people care outside of those who are aware
            of REST), and you have to explicitly configure the modules to
            distinguish between the url-encoded entity body and the query string.

            i just read STDIN or the QUERY_STRING environment variable and use a
            hash keyed on the value of Content-type header to pick out an
            appropriate parser. if you want me to elaborate on this chris, let me
            know; i have a CGI script doing this.

            i'm using this in combination with mod_rewrite to have nice URIs which
            reflect the hierarchy. this isn't strictly a requirement of being
            RESTful; i just like it this way. it keeps verbs out of the URIs, they
            only have nouns in them.

            i am working on a system for tracking fund-raising.

            i have mod_rewrite rules in apache which do the following:

            /contributors/?foo=bar becomes
            /cgi-bin/contributors/index.cgi?foo=bar
            /contributors/12345 becomes
            /cgi-bin/contributors/one.cgi?id=12345
            /contributors/12345?foo=bar becomes
            /cgi-bin/contributors/one.cgi?id=12345&foo=bar

            and so on. each CGI script handles all requests (GET, POST for know
            because that's all the clients support).

            i'm toying with the idea of boiling this stuff down into a CPAN module
            called CGI::Resource or something; maybe when i have a bit more
            experience of how well this works in practice. if anybody wants
            boilerplate source shout.

            to answer your question, POSTing to a URI with a querystring is
            definitely possible, and probably OK. i prefer to use querystrings for
            queries parameters only as much as possible, but pragmatism wins out
            easily over that most of the time. the tool support for eliminating
            querystrings except for queries isn't really there (yet). hence my
            wrestling with mod_rewrite.

            regards,
            -vincent
          • S. Mike Dierken
            ... From: Vincent D Murphy ... This is very nice - what do the rules look like? (I don t know the Apache syntax) This is a good idea even
            Message 5 of 8 , Oct 10, 2002
            • 0 Attachment
              ----- Original Message -----
              From: "Vincent D Murphy" <vdm@...>

              >
              > i have mod_rewrite rules in apache which do the following:
              >
              > /contributors/?foo=bar becomes
              > /cgi-bin/contributors/index.cgi?foo=bar
              > /contributors/12345 becomes
              > /cgi-bin/contributors/one.cgi?id=12345
              > /contributors/12345?foo=bar becomes
              > /cgi-bin/contributors/one.cgi?id=12345&foo=bar
              >
              > and so on. each CGI script handles all requests (GET, POST for know
              > because that's all the clients support).
              This is very nice - what do the rules look like? (I don't know the Apache
              syntax)

              This is a good idea even independent of REST since the public URL doesn't
              have name of the implementation file (one.cgi) which could change if the
              system migrates to another technology (e.g. one.jsp). The URLs have a longer
              lifetime and this is good.
            • Vincent D Murphy
              here s my .htaccess. RewriteEngine on RewriteBase /foo RewriteRule ^contributors$ contributors/ [R=permanent] RewriteRule ^contributors/$
              Message 6 of 8 , Oct 11, 2002
              • 0 Attachment
                here's my .htaccess.

                RewriteEngine on
                RewriteBase /foo
                RewriteRule ^contributors$ contributors/ [R=permanent]
                RewriteRule ^contributors/$ cgi/contributors/index.pl.cgi
                RewriteRule ^contributors/([0-9]+)[/]?$
                cgi/contributors/one.pl.cgi?id=$1

                RewriteBase sets the 'root' of your URL. it could be just slash /, but
                i used /foo because there are other things living on the root of the
                same httpd.

                overall i found mod_rewrite to be a total pain in the ass (it took me a
                whole day to come up with these simple rules) but i'm of the opinion
                that it was worth it.
              • Jan Algermissen
                ... Hmm, technically I will be writing an Apache module. Am I correctly assuming that Apache itself does not have problems with this ? The reason why I need to
                Message 7 of 8 , Oct 11, 2002
                • 0 Attachment
                  Chris Croome wrote:
                  >
                  > Hi
                  >
                  > On Thu 10-Oct-2002 at 07:09:02PM +0200, Jan Algermissen wrote:
                  > >
                  > > Can I POST to a URI that contains a query string ?
                  >
                  > We haven't had any luck doing that with Apache and Perl, the result
                  > is always the same as posting without the query string.

                  Hmm, technically I will be writing an Apache module. Am I correctly assuming
                  that Apache itself does not have problems with this ?


                  The reason why I need to use a query string is that URIs will be part of
                  my web service URIs

                  Here is a fictitious example:

                  Suppose there is a web service that serves manuals for all kinds
                  of technical goods, among them air conditioner XYZ. Also suppose that
                  the only way to tell the services which machine's manual I need to see
                  is via a URI. I would have to issue requests such as

                  GET /documentation/manuals?item=http://www.brandX.com/products/air-contitioners#XYZ

                  (not url encoded for clarity)

                  Would there be any way to put the air conditioner's URI into the service's
                  URI other than via a query string ?



                  Jan



                  >
                  > Populating the form with the information from the query string
                  > seems the most logical thing to do.
                  >
                  > Chris
                  >
                  > --
                  > Chris Croome <chris@...>
                  > web design http://www.webarchitects.co.uk/
                  > web content management http://mkdoc.com/
                  > everything else http://chris.croome.net/
                  >
                  >
                  > To unsubscribe from this group, send an email to:
                  > rest-discuss-unsubscribe@yahoogroups.com
                  >
                  >
                  >
                  > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

                  --
                  Jan Algermissen
                  Consultant & Programmer

                  Tel: ++49 (0)40 89 700 511
                  ++49 (0)177 283 1440
                  Fax: ++49 (0)40 89 700 841
                  Email: algermissen@...
                  Web: http://www.topicmapping.com
                • S. Mike Dierken
                  ... From: Jan Algermissen ... /documentation/manuals?item=http://www.brandX.com/products/air-contitioners# XYZ ... If this is not
                  Message 8 of 8 , Oct 11, 2002
                  • 0 Attachment
                    ----- Original Message -----
                    From: "Jan Algermissen" <algermissen@...>

                    > Here is a fictitious example:
                    >
                    > Suppose there is a web service that serves manuals for all kinds
                    > of technical goods, among them air conditioner XYZ. Also suppose that
                    > the only way to tell the services which machine's manual I need to see
                    > is via a URI. I would have to issue requests such as
                    >
                    > GET
                    /documentation/manuals?item=http://www.brandX.com/products/air-contitioners#
                    XYZ
                    >
                    > (not url encoded for clarity)
                    >
                    > Would there be any way to put the air conditioner's URI into the service's
                    > URI other than via a query string ?
                    If this is not purely a pass-through - the brandX.com is a registered data
                    entity on your server - then you don't have to have http: in there. You
                    would use an id that your server knew about, do the lookup to the base URL
                    for the third party, and merge some text strings.

                    If you don't need the protocol portion, you can just put it in a path
                    segment (between the '/' characters). You can define for your internal
                    implementation that any segments past a certain point are part of the other
                    site.

                    GET /documentation/manuals/www.brandX.com/products/air-contitioners#XYZ

                    If you do need the protocol, then you probably need a query string.
                  Your message has been successfully submitted and would be delivered to recipients shortly.