How do make it post instead of get?

  • Thread starter Flemming Munk jensen
  • Start date
F

Flemming Munk jensen

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
 
P

Paul Smith

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


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

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

(e-mail address removed)
 
F

Flemming Munk jensen

Paul said:
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://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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top