How do make it post instead of get?

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

/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-forum.com/\.

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
>/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-forum.com/\.

--
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

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 :wink:

I have a webpage on a m0n0wall (see http://m0n0.ch/wall/\) 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-forum.com/\.