[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How do make it post instead of get?

Flemming Munk jensen

7/9/2008 1:34:00 PM

This script will GET the page i request when i call it from dos-prompt
like this "ruby nukeuser.rb 1"

--------------------------------------------------
require 'uri'
require 'net/https'

user_id = ARGV[0].strip
url = "https://<ip
address>/services_captiveportal_users.php?act=del&id=" + user_id

url1 = URI.parse(url)

http = Net::HTTP.new(url1.host, url1.port)
http.use_ssl = true
# Do not warn us about certificate - blithely accept whatever
certificate we receive!
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

req = Net::HTTP::Get.new(url1.path)
req.basic_auth 'username', 'password'

res = http.start do |h|
h.request(req)
end

print res.body

--------------------------------------------------

But i really need to POST... and cant figure out how to make it do that
:-/
Can someone please help - i am loosing my hair fast at the moment!
--
Posted via http://www.ruby-....

5 Answers

Paul Smith

7/9/2008 1:37:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

Change

req = Net::HTTP::Get.new(url1.path)

to

req = Net::HTTP::Post.new(url1.path)

?

On Wed, Jul 9, 2008 at 2:33 PM, Flemming Munk jensen <
flemming@munkjensen.net> wrote:

> This script will GET the page i request when i call it from dos-prompt
> like this "ruby nukeuser.rb 1"
>
> --------------------------------------------------
> require 'uri'
> require 'net/https'
>
> user_id = ARGV[0].strip
> url = "https://<ip
> address>/services_captiveportal_users.php?act=del&id=" + user_id
>
> url1 = URI.parse(url)
>
> http = Net::HTTP.new(url1.host, url1.port)
> http.use_ssl = true
> # Do not warn us about certificate - blithely accept whatever
> certificate we receive!
> http.verify_mode = OpenSSL::SSL::VERIFY_NONE
>
> req = Net::HTTP::Get.new(url1.path)
> req.basic_auth 'username', 'password'
>
> res = http.start do |h|
> h.request(req)
> end
>
> print res.body
>
> --------------------------------------------------
>
> But i really need to POST... and cant figure out how to make it do that
> :-/
> Can someone please help - i am loosing my hair fast at the moment!
> --
> Posted via http://www.ruby-....
>
>


--
Paul Smith
DCI Level 2 Judge, Bath FNM Organiser

Upcoming events in Bath - nomadicfun.co.uk
July 12th Eventide Prerelease (Standard)

paul@pollyandpaul.co.uk

Flemming Munk jensen

7/10/2008 6:23:00 AM

0

Paul Smith wrote:
> Change
>
> req = Net::HTTP::Get.new(url1.path)
>
> to
>
> req = Net::HTTP::Post.new(url1.path)
>
> ?
>

Well... that run's without any errors too, but i dont get the result i
would like.

I think i will explain a little more about what i am trying to do ;-)

I have a webpage on a m0n0wall (see http://m0n...) where you can
do some user management. On this page is a link that is marked up like
this:

<A onclick="return confirm('Do you really want to delete this user?')"
href="services_captiveportal_users.php?act=del&amp;id=1">
<IMG title="delete user" height=17 src="x.gif" width=17 border=0>
</A>

Now what i want ruby to do is call the page
services_captiveportal_users.php with the action "act=del" and the
apropriate "id=?", so i can delete users this way.

What happens so far, is i get the page with a list of all users
currently registered, wich is ok, but the user id i request to be
deleted is not deleted??

Is it maybe because of the "onclick="return...blah" in the href??
I have the feeling i am missing some basic law of nature here, and in
the process of embarassing myself bigtime...

Thanks in advantage

BR
Flemming






--
Posted via http://www.ruby-....

Eddie Haskell

7/9/2012 6:32:00 PM

0


"MattB" <trdell1234NOMORESPAM@gmail.com> wrote in message
news:s78mv7dee78a9bkndl486njdfv0araobgc@4ax.com...
> On Mon, 9 Jul 2012 13:16:13 -0500, "Eddie Haskell" <waek@wroj.com>
> wrote:
>
>>
>>"MattB" <trdell1234NOMORESPAM@gmail.com> wrote in message
>>news:557mv75s44qbs8bk3l7ab6mbm5bkun4vs7@4ax.com...
>>> CNN Poll: Was politics behind Holder contempt vote?
>>>
>>> http://politicalticker.blogs.cnn.com/2012/07/09/cnn-poll-was-politics-behind-holder-cont...
>>>
>>> Washington (CNN) - Most Americans approve of the decision by the House
>>> of Representatives to censure Attorney General Eric Holder, but a new
>>> national poll also indicates that a majority of the public thinks that
>>> House Republicans are investigating Holder to gain political
>>> advantage.
>>>
>>> According to a CNN/ORC International survey released Monday morning,
>>> 53% of people questioned say they approve of the House vote a week and
>>> a half ago to hold the attorney general in contempt of Congress for
>>> refusing to turn over documents related to a controversial program
>>> called Operation Fast and Furious, with one in three saying they
>>> disapprove of the move and 13% unsure.
>>
>>And just think how high the percentage would be if most people knew a damn
>>thing about it?
>>
>>-Eddie Haskell
>>
>
>
> Sadly US news sources are highly biased on so many issues. Me I
> wonder what Obama is hiding.

The fact that the whole thing was a ruse to prove the long held liberal lie
that US gun dealers were supplying Mexican drug gangs so as to mount an
attack on the constitution and the second amendment.

-Eddie Haskell


MattB

7/9/2012 6:37:00 PM

0

On Mon, 9 Jul 2012 13:32:13 -0500, "Eddie Haskell" <waek@wroj.com>
wrote:

>
>"MattB" <trdell1234NOMORESPAM@gmail.com> wrote in message
>news:s78mv7dee78a9bkndl486njdfv0araobgc@4ax.com...
>> On Mon, 9 Jul 2012 13:16:13 -0500, "Eddie Haskell" <waek@wroj.com>
>> wrote:
>>
>>>
>>>"MattB" <trdell1234NOMORESPAM@gmail.com> wrote in message
>>>news:557mv75s44qbs8bk3l7ab6mbm5bkun4vs7@4ax.com...
>>>> CNN Poll: Was politics behind Holder contempt vote?
>>>>
>>>> http://politicalticker.blogs.cnn.com/2012/07/09/cnn-poll-was-politics-behind-holder-cont...
>>>>
>>>> Washington (CNN) - Most Americans approve of the decision by the House
>>>> of Representatives to censure Attorney General Eric Holder, but a new
>>>> national poll also indicates that a majority of the public thinks that
>>>> House Republicans are investigating Holder to gain political
>>>> advantage.
>>>>
>>>> According to a CNN/ORC International survey released Monday morning,
>>>> 53% of people questioned say they approve of the House vote a week and
>>>> a half ago to hold the attorney general in contempt of Congress for
>>>> refusing to turn over documents related to a controversial program
>>>> called Operation Fast and Furious, with one in three saying they
>>>> disapprove of the move and 13% unsure.
>>>
>>>And just think how high the percentage would be if most people knew a damn
>>>thing about it?
>>>
>>>-Eddie Haskell
>>>
>>
>>
>> Sadly US news sources are highly biased on so many issues. Me I
>> wonder what Obama is hiding.
>
>The fact that the whole thing was a ruse to prove the long held liberal lie
>that US gun dealers were supplying Mexican drug gangs so as to mount an
>attack on the constitution and the second amendment.

OBOBO would never do that. Let innocent Latino Women and Children and
our own citizens get killed just for his agenda. Then again.
>
>-Eddie Haskell
>

Eddie Haskell

7/9/2012 6:49:00 PM

0


"MattB" <trdell1234NOMORESPAM@gmail.com> wrote in message
news:c49mv7d029a3p77iadhe84t9egkf4a3hp0@4ax.com...
> On Mon, 9 Jul 2012 13:32:13 -0500, "Eddie Haskell" <waek@wroj.com>
> wrote:
>
>>
>>"MattB" <trdell1234NOMORESPAM@gmail.com> wrote in message
>>news:s78mv7dee78a9bkndl486njdfv0araobgc@4ax.com...
>>> On Mon, 9 Jul 2012 13:16:13 -0500, "Eddie Haskell" <waek@wroj.com>
>>> wrote:
>>>
>>>>
>>>>"MattB" <trdell1234NOMORESPAM@gmail.com> wrote in message
>>>>news:557mv75s44qbs8bk3l7ab6mbm5bkun4vs7@4ax.com...
>>>>> CNN Poll: Was politics behind Holder contempt vote?
>>>>>
>>>>> http://politicalticker.blogs.cnn.com/2012/07/09/cnn-poll-was-politics-behind-holder-cont...
>>>>>
>>>>> Washington (CNN) - Most Americans approve of the decision by the House
>>>>> of Representatives to censure Attorney General Eric Holder, but a new
>>>>> national poll also indicates that a majority of the public thinks that
>>>>> House Republicans are investigating Holder to gain political
>>>>> advantage.
>>>>>
>>>>> According to a CNN/ORC International survey released Monday morning,
>>>>> 53% of people questioned say they approve of the House vote a week and
>>>>> a half ago to hold the attorney general in contempt of Congress for
>>>>> refusing to turn over documents related to a controversial program
>>>>> called Operation Fast and Furious, with one in three saying they
>>>>> disapprove of the move and 13% unsure.
>>>>
>>>>And just think how high the percentage would be if most people knew a
>>>>damn
>>>>thing about it?
>>>>
>>>>-Eddie Haskell
>>>>
>>>
>>>
>>> Sadly US news sources are highly biased on so many issues. Me I
>>> wonder what Obama is hiding.
>>
>>The fact that the whole thing was a ruse to prove the long held liberal
>>lie
>>that US gun dealers were supplying Mexican drug gangs so as to mount an
>>attack on the constitution and the second amendment.
>
> OBOBO would never do that. Let innocent Latino Women and Children and
> our own citizens get killed just for his agenda. Then again.

His whole reelection bid is about putting himself ahead of the good of the
country.

-Eddie Haskell