HTTP::Post - HTTP::Get (Can someone help me?)

Discussion in 'Ruby' started by Fred, Apr 23, 2008.

  1. Fred

    Fred Guest

    Hello,

    I'm lost.
    Can someone explain good to me what the difference is between these 2
    methods?

    I have a HTTP:post and when i check the body, i see exacly what he has
    to do. But it doesn't do it in reality.
    How can i resolve the problem?

    thank you
    Fred, Apr 23, 2008
    #1
    1. Advertising

  2. Fred

    darren kirby Guest

    quoth the Fred:
    > Hello,
    >
    > I'm lost.
    > Can someone explain good to me what the difference is between these 2
    > methods?


    'GET' and 'POST' are two 'request methods' which are part of the HTTP spec.
    Your two methods are ruby implementations of such request methods. Read this:
    http://en.wikipedia.org/wiki/Http#Request_methods

    ...and you will see they are quite different.

    > I have a HTTP:post and when i check the body, i see exacly what he has
    > to do. But it doesn't do it in reality.
    > How can i resolve the problem?


    I have no idea what you are getting at here. Please repost with:
    * A clear description of what you want to accomplish
    * How what you are doing now is failing (include error messages)
    * Your failing code
    * excerpt of your data causing a failure (if applicable)

    If you include all this, you will certainly recieve a more helpful response.

    > thank you


    -d
    --
    darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
    "...the number of UNIX installations has grown to 10, with more expected..."
    - Dennis Ritchie and Ken Thompson, June 1972
    darren kirby, Apr 23, 2008
    #2
    1. Advertising

  3. Fred

    Fred Guest

    Thanx Darren for the info

    What i want to do:

    Interact with a site and change behaviour without going to the site itself.

    I have to do 2 steps.


    def connect
    uri = URI.parse(BASE_ADDRESS)
    HTTP.version_1_1
    @http = HTTP.start(uri.host, uri.port)
    end

    1. The first one succeed with

    connect
    req = HTTP::post.new("...")
    add_headers req, "......"
    res = @http.request(req)
    puts res.body
    @http.finish

    When i look into res.body i see that the first step is good.

    2. Now the second step is to simulate a POST (submit button) from the
    first step.

    req = HTTP::post.new("....")
    add_headers req, "...."
    connect
    res = @http.request(req)
    puts res.body
    @http.finish

    When i look into res.body i see nothing.
    I also tried the connect before the req in the second step but it
    changed nothing.

    The second step has to change the first step ( activate the submit
    button) but it doesn't work.

    I hope you understand it a little bit.

    Can someone help me with this?

    Thanks



    darren kirby schreef:
    > quoth the Fred:
    >> Hello,
    >>
    >> I'm lost.
    >> Can someone explain good to me what the difference is between these 2
    >> methods?

    >
    > 'GET' and 'POST' are two 'request methods' which are part of the HTTP spec.
    > Your two methods are ruby implementations of such request methods. Read this:
    > http://en.wikipedia.org/wiki/Http#Request_methods
    >
    > ..and you will see they are quite different.
    >
    >> I have a HTTP:post and when i check the body, i see exacly what he has
    >> to do. But it doesn't do it in reality.
    >> How can i resolve the problem?

    >
    > I have no idea what you are getting at here. Please repost with:
    > * A clear description of what you want to accomplish
    > * How what you are doing now is failing (include error messages)
    > * Your failing code
    > * excerpt of your data causing a failure (if applicable)
    >
    > If you include all this, you will certainly recieve a more helpful response.
    >
    >> thank you

    >
    > -d
    Fred, Apr 24, 2008
    #3
  4. Fred

    7stud -- Guest

    What's in step 1's resp.body? Is it html? Do you want to extract a url
    from that html and send a request to that url?
    --
    Posted via http://www.ruby-forum.com/.
    7stud --, Apr 24, 2008
    #4
  5. Fred

    Fred Guest

    resp.body is a php page => purpose is to see of step 1 is working

    7stud -- schreef:
    > What's in step 1's resp.body? Is it html? Do you want to extract a url
    > from that html and send a request to that url?



    Fred schreef:
    > Thanx Darren for the info
    >
    > What i want to do:
    >
    > Interact with a site and change behaviour without going to the site itself.
    >
    > I have to do 2 steps.
    >
    >
    > def connect
    > uri = URI.parse(BASE_ADDRESS)
    > HTTP.version_1_1
    > @http = HTTP.start(uri.host, uri.port)
    > end
    >
    > 1. The first one succeed with
    >
    > connect
    > req = HTTP::post.new("...")
    > add_headers req, "......"
    > res = @http.request(req)
    > puts res.body
    > @http.finish
    >
    > When i look into res.body i see that the first step is good.
    >
    > 2. Now the second step is to simulate a POST (submit button) from the
    > first step.
    >
    > req = HTTP::post.new("....")
    > add_headers req, "...."
    > connect
    > res = @http.request(req)
    > puts res.body
    > @http.finish
    >
    > When i look into res.body i see nothing.
    > I also tried the connect before the req in the second step but it
    > changed nothing.
    >
    > The second step has to change the first step ( activate the submit
    > button) but it doesn't work.
    >
    > I hope you understand it a little bit.
    >
    > Can someone help me with this?
    >
    > Thanks
    >
    >
    >
    > darren kirby schreef:
    >> quoth the Fred:
    >>> Hello,
    >>>
    >>> I'm lost.
    >>> Can someone explain good to me what the difference is between these 2
    >>> methods?

    >>
    >> 'GET' and 'POST' are two 'request methods' which are part of the HTTP
    >> spec. Your two methods are ruby implementations of such request
    >> methods. Read this: http://en.wikipedia.org/wiki/Http#Request_methods
    >>
    >> ..and you will see they are quite different.
    >>
    >>> I have a HTTP:post and when i check the body, i see exacly what he has
    >>> to do. But it doesn't do it in reality.
    >>> How can i resolve the problem?

    >>
    >> I have no idea what you are getting at here. Please repost with:
    >> * A clear description of what you want to accomplish
    >> * How what you are doing now is failing (include error messages)
    >> * Your failing code
    >> * excerpt of your data causing a failure (if applicable)
    >>
    >> If you include all this, you will certainly recieve a more helpful
    >> response.
    >>
    >>> thank you

    >>
    >> -d
    Fred, Apr 24, 2008
    #5
  6. Fred

    Fred Guest

    The First step is to insert javascript into PHP page.
    In puts res.body i can see if it works and it works.
    The second step is to activate the submit button from the first step,
    and this isn't working.

    thnx

    Fred schreef:
    > resp.body is a php page => purpose is to see of step 1 is working
    >
    > 7stud -- schreef:
    > > What's in step 1's resp.body? Is it html? Do you want to extract a url
    > > from that html and send a request to that url?

    >
    >
    > Fred schreef:
    >> Thanx Darren for the info
    >>
    >> What i want to do:
    >>
    >> Interact with a site and change behaviour without going to the site
    >> itself.
    >>
    >> I have to do 2 steps.
    >>
    >>
    >> def connect
    >> uri = URI.parse(BASE_ADDRESS)
    >> HTTP.version_1_1
    >> @http = HTTP.start(uri.host, uri.port)
    >> end
    >>
    >> 1. The first one succeed with
    >>
    >> connect
    >> req = HTTP::post.new("...")
    >> add_headers req, "......"
    >> res = @http.request(req)
    >> puts res.body
    >> @http.finish
    >>
    >> When i look into res.body i see that the first step is good.
    >>
    >> 2. Now the second step is to simulate a POST (submit button) from the
    >> first step.
    >>
    >> req = HTTP::post.new("....")
    >> add_headers req, "...."
    >> connect
    >> res = @http.request(req)
    >> puts res.body
    >> @http.finish
    >>
    >> When i look into res.body i see nothing.
    >> I also tried the connect before the req in the second step but it
    >> changed nothing.
    >>
    >> The second step has to change the first step ( activate the submit
    >> button) but it doesn't work.
    >>
    >> I hope you understand it a little bit.
    >>
    >> Can someone help me with this?
    >>
    >> Thanks
    >>
    >>
    >>
    >> darren kirby schreef:
    >>> quoth the Fred:
    >>>> Hello,
    >>>>
    >>>> I'm lost.
    >>>> Can someone explain good to me what the difference is between these 2
    >>>> methods?
    >>>
    >>> 'GET' and 'POST' are two 'request methods' which are part of the HTTP
    >>> spec. Your two methods are ruby implementations of such request
    >>> methods. Read this: http://en.wikipedia.org/wiki/Http#Request_methods
    >>>
    >>> ..and you will see they are quite different.
    >>>
    >>>> I have a HTTP:post and when i check the body, i see exacly what he has
    >>>> to do. But it doesn't do it in reality.
    >>>> How can i resolve the problem?
    >>>
    >>> I have no idea what you are getting at here. Please repost with:
    >>> * A clear description of what you want to accomplish
    >>> * How what you are doing now is failing (include error messages)
    >>> * Your failing code
    >>> * excerpt of your data causing a failure (if applicable)
    >>>
    >>> If you include all this, you will certainly recieve a more helpful
    >>> response.
    >>>
    >>>> thank you
    >>>
    >>> -d
    Fred, Apr 24, 2008
    #6
  7. Fred

    Avdi Grimm Guest

    On Thu, Apr 24, 2008 at 6:30 AM, Fred <> wrote:
    > The First step is to insert javascript into PHP page.
    > In puts res.body i can see if it works and it works.
    > The second step is to activate the submit button from the first step, and
    > this isn't working.


    What status code is the second request returning?

    --
    Avdi

    Home: http://avdi.org
    Developer Blog: http://avdi.org/devblog/
    Twitter: http://twitter.com/avdi
    Journal: http://avdi.livejournal.com
    Avdi Grimm, Apr 24, 2008
    #7
  8. Fred

    Fred Guest

    Avdi Grimm schreef:
    > On Thu, Apr 24, 2008 at 6:30 AM, Fred <> wrote:
    >> The First step is to insert javascript into PHP page.
    >> In puts res.body i can see if it works and it works.
    >> The second step is to activate the submit button from the first step, and
    >> this isn't working.

    >
    > What status code is the second request returning?
    >


    Do you mean what he returns when i puts res.body?

    He doesn't output anything?
    Fred, Apr 24, 2008
    #8
  9. Fred

    Avdi Grimm Guest

    I mean the HTTP status code - e.g. 302, 200, 404, etc. What is the
    value of the response.code and response.message?

    On 4/24/08, Fred <> wrote:
    > Avdi Grimm schreef:
    > > On Thu, Apr 24, 2008 at 6:30 AM, Fred <> wrote:
    > >> The First step is to insert javascript into PHP page.
    > >> In puts res.body i can see if it works and it works.
    > >> The second step is to activate the submit button from the first step,

    > and
    > >> this isn't working.

    > >
    > > What status code is the second request returning?
    > >

    >
    > Do you mean what he returns when i puts res.body?
    >
    > He doesn't output anything?
    >
    >


    --
    Sent from Gmail for mobile | mobile.google.com

    Avdi

    Home: http://avdi.org
    Developer Blog: http://avdi.org/devblog/
    Twitter: http://twitter.com/avdi
    Journal: http://avdi.livejournal.com
    Avdi Grimm, Apr 24, 2008
    #9
  10. Fred

    Fred Guest

    puts "#{res.code} #{res.message}\n"

    Gives me:

    302 Found


    Avdi Grimm schreef:
    > I mean the HTTP status code - e.g. 302, 200, 404, etc. What is the
    > value of the response.code and response.message?
    >
    > On 4/24/08, Fred <> wrote:
    >> Avdi Grimm schreef:
    >>> On Thu, Apr 24, 2008 at 6:30 AM, Fred <> wrote:
    >>>> The First step is to insert javascript into PHP page.
    >>>> In puts res.body i can see if it works and it works.
    >>>> The second step is to activate the submit button from the first step,

    >> and
    >>>> this isn't working.
    >>> What status code is the second request returning?
    >>>

    >> Do you mean what he returns when i puts res.body?
    >>
    >> He doesn't output anything?
    >>
    >>

    >
    Fred, Apr 24, 2008
    #10
  11. Fred

    7stud -- Guest

    Fred wrote:
    > The First step is to insert javascript into PHP page.
    > In puts res.body i can see if it works and it works.
    > The second step is to activate the submit button from the first step,
    > and this isn't working.
    >


    Of course that doesn't make any sense.

    submit button = html
    first step = javascript
    javascript != html
    --> first step != submit button.

    --
    Posted via http://www.ruby-forum.com/.
    7stud --, Apr 24, 2008
    #11
  12. Fred

    Fred Guest

    i can't follow you:

    Do you mean, that there can not be an submit button on a php page?

    7stud -- schreef:
    > Fred wrote:
    >> The First step is to insert javascript into PHP page.
    >> In puts res.body i can see if it works and it works.
    >> The second step is to activate the submit button from the first step,
    >> and this isn't working.
    >>

    >
    > Of course that doesn't make any sense.
    >
    > submit button = html
    > first step = javascript
    > javascript != html
    > --> first step != submit button.
    >
    Fred, Apr 24, 2008
    #12
  13. Fred

    7stud -- Guest

    Fred wrote:
    > i can't follow you:
    >
    > Do you mean, that there can not be an submit button on a php page?
    >
    > 7stud -- schreef:


    Here's the deal. You can make requests to urls. Then a response will
    be sent back. There are no submit buttons: there are only urls and
    requests. So, you need to figure out what url you want to send a
    request to. If you send a request to that url and you don't get the
    response you want, then you either have a problem with your request, or
    there is a problem on the server side.
    --
    Posted via http://www.ruby-forum.com/.
    7stud --, Apr 25, 2008
    #13
  14. Fred

    Fred Guest

    7stud -- schreef:
    > Fred wrote:
    >> i can't follow you:
    >>
    >> Do you mean, that there can not be an submit button on a php page?
    >>
    >> 7stud -- schreef:

    >
    > Here's the deal. You can make requests to urls. Then a response will
    > be sent back. There are no submit buttons: there are only urls and
    > requests. So, you need to figure out what url you want to send a
    > request to. If you send a request to that url and you don't get the
    > response you want, then you either have a problem with your request, or
    > there is a problem on the server side.


    Thanks for explanation

    Sorry, but i still don't understand.

    In the first step when i do an HTTP:post.new, i can change the behaviour
    of the php page, that he inserts some stuff and submit an button, i can
    see that when i call puts res.body.
    My problem is that after the first step, i have again an submit tbutton
    that i want to activate.
    Fred, Apr 25, 2008
    #14
  15. Fred

    7stud -- Guest

    Fred wrote:
    > 7stud -- schreef:
    >> request to. If you send a request to that url and you don't get the
    >> response you want, then you either have a problem with your request, or
    >> there is a problem on the server side.

    >
    > Thanks for explanation
    >
    > Sorry, but i still don't understand.
    >
    > In the first step when i do an HTTP:post.new, i can change the behaviour
    > of the php page, that he inserts some stuff and submit an button, i can
    > see that when i call puts res.body.
    > My problem is that after the first step, i have again an submit tbutton
    > that i want to activate.


    This is the way a submit works. The submit button is part of a form.
    The form has an action attribute. The action attribute specifies a url.
    When you click on a submit button that is displayed on a web page, all
    the information entered into the form is inserted into a request. The
    request is then sent to the url listed in the action attribute.

    In your ruby program, there are no submit buttons. You only have a
    string with some html in it(resp.body). Therefore, if you want to send
    a request, you need to decide what url to send the request to. If you
    want to simulate clicking on a specific submit button, then you need to
    send a request to the url specified in the action attribute of the form
    that contains the submit button. The request should contain any
    information that would have been entered in the form. That means you
    have to search resp.body for the url that you want to send your request
    to, and your request has to contain all the information that you would
    have entered in the form.

    --
    Posted via http://www.ruby-forum.com/.
    7stud --, Apr 25, 2008
    #15
  16. Fred

    Fred Guest

    7stud -- schreef:
    > Fred wrote:
    >> 7stud -- schreef:
    >>> request to. If you send a request to that url and you don't get the
    >>> response you want, then you either have a problem with your request, or
    >>> there is a problem on the server side.

    >> Thanks for explanation
    >>
    >> Sorry, but i still don't understand.
    >>
    >> In the first step when i do an HTTP:post.new, i can change the behaviour
    >> of the php page, that he inserts some stuff and submit an button, i can
    >> see that when i call puts res.body.
    >> My problem is that after the first step, i have again an submit tbutton
    >> that i want to activate.

    >
    > This is the way a submit works. The submit button is part of a form.
    > The form has an action attribute. The action attribute specifies a url.
    > When you click on a submit button that is displayed on a web page, all
    > the information entered into the form is inserted into a request. The
    > request is then sent to the url listed in the action attribute.
    >
    > In your ruby program, there are no submit buttons. You only have a
    > string with some html in it(resp.body). Therefore, if you want to send
    > a request, you need to decide what url to send the request to. If you
    > want to simulate clicking on a specific submit button, then you need to
    > send a request to the url specified in the action attribute of the form
    > that contains the submit button. The request should contain any
    > information that would have been entered in the form. That means you
    > have to search resp.body for the url that you want to send your request
    > to, and your request has to contain all the information that you would
    > have entered in the form.
    >


    Thanks again for clarification

    This is also what i'm doing. I didn't explain it very well.
    In the first step i'm simulating the submit button like you explained
    it. In my resp.body after the first step, i can see that it succeeded.
    But my problem is in the second step, i want to simulate again a submit
    button from the first step, this is not working and i don't know what
    i'm doing wrong.

    First step:

    req = HTTP::post.new("..")
    add_headers req, ".."
    req.body = body
    print "First step"
    res = @http.request(req)
    puts res.body
    @http.finish

    Second step:

    req = HTTP::post.new("..")
    add_headers req, ".."
    req.body = body
    print "Second step..."
    res = @http.request(req)
    puts res.body
    @http.finish
    Fred, Apr 25, 2008
    #16
  17. Fred

    7stud -- Guest

    Fred wrote:
    > First step:
    >
    > req = HTTP::post.new("..")
    > add_headers req, ".."
    > req.body = body
    > print "First step"
    > res = @http.request(req)
    > puts res.body
    > @http.finish
    >
    > Second step:
    >
    > req = HTTP::post.new("..")
    > add_headers req, ".."
    > req.body = body
    > print "Second step..."
    > res = @http.request(req)
    > puts res.body
    > @http.finish


    Since you refuse to post any details, like the html and the url, how do
    you expect anybody to be able to help you? And suddenly you can
    speak english? Or, were you on medication durin your first 3 posts?
    --
    Posted via http://www.ruby-forum.com/.
    7stud --, Apr 25, 2008
    #17
  18. Fred

    Fred Guest

    7stud -- schreef:
    > Fred wrote:
    >> First step:
    >>
    >> req = HTTP::post.new("..")
    >> add_headers req, ".."
    >> req.body = body
    >> print "First step"
    >> res = @http.request(req)
    >> puts res.body
    >> @http.finish
    >>
    >> Second step:
    >>
    >> req = HTTP::post.new("..")
    >> add_headers req, ".."
    >> req.body = body
    >> print "Second step..."
    >> res = @http.request(req)
    >> puts res.body
    >> @http.finish

    >
    > Since you refuse to post any details, like the html and the url, how do
    > you expect anybody to be able to help you? And suddenly you can
    > speak english? Or, were you on medication durin your first 3 posts?


    Can i email you the details?
    Englisch is defintaly not my first language and no, i don't take medicine

    Thnx
    Fred, Apr 25, 2008
    #18
    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. Teep
    Replies:
    1
    Views:
    316
    Rick Spiewak
    Jun 27, 2004
  2. Andreas Sheriff
    Replies:
    10
    Views:
    716
    Jack Klein
    Sep 25, 2004
  3. serge calderara

    HTTP GET vs HTTP POST protocol

    serge calderara, Nov 4, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    570
  4. Mike
    Replies:
    1
    Views:
    138
    kaeli
    Sep 8, 2004
  5. Jack
    Replies:
    9
    Views:
    184
Loading...

Share This Page