2023-12-11 20:56:09 +00:00
|
|
|
require 'net/http'
|
|
|
|
require 'uri'
|
|
|
|
|
|
|
|
# The URL you want to send the POST request to
|
|
|
|
url = URI.parse('http://localhost:4567/auth/login')
|
|
|
|
|
|
|
|
# Create a new Net::HTTP object with the target server
|
|
|
|
http = Net::HTTP.new(url.host, url.port)
|
|
|
|
|
|
|
|
# If your server uses HTTPS, you might need to enable SSL
|
|
|
|
# http.use_ssl = true
|
|
|
|
|
|
|
|
# Create a new Net::HTTP::Post request with the desired path
|
|
|
|
request = Net::HTTP::Post.new(url.path)
|
|
|
|
|
|
|
|
# Set the request body with the data you want to send
|
2023-12-12 22:52:36 +00:00
|
|
|
request.body = 'username=admin&password=pass1re23'
|
2023-12-11 20:56:09 +00:00
|
|
|
|
|
|
|
# Set the 'Content-Type' header if needed
|
|
|
|
request['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
|
|
|
|
|
|
# Send the request and get the response
|
|
|
|
response = http.request(request)
|
|
|
|
|
|
|
|
# Output the response
|
|
|
|
puts "Response Code: #{response.code}"
|
|
|
|
puts "Response Body: #{response.body}"
|