From a3fbc9e6812f624279c1f82b31c8bbe5169e0b89 Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Sat, 16 Nov 2013 09:58:26 -0500 Subject: [PATCH] Revert "Adds Basic HTTP Auth support" This reverts commit 1cdb3b77462b04411923e87cfebc27e05b0289d4. --- README.md | 8 -------- lib/haste.rb | 16 +++++----------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index eb9609c..a625c4b 100644 --- a/README.md +++ b/README.md @@ -47,14 +47,6 @@ alias work_haste="HASTE_SERVER=http://something.com haste" After which you can use `work_haste` to send hastes to that server instead. -### Basic Auth - -If your haste-server requires basic http authentication, you can use: - -``` bash -HASTE_SERVER=http://something.com HASTE_USER=user HASTE_PWD=pass haste some_file.txt -``` - ## Windows Support If you'd like an alternative on Windows that supports functionality similar to `pbcopy`, check out Aidan Ryan's [WinHaste](https://github.com/ajryan/WinHaste) project. diff --git a/lib/haste.rb b/lib/haste.rb index 68763c2..229e88a 100644 --- a/lib/haste.rb +++ b/lib/haste.rb @@ -16,8 +16,6 @@ module Haste abort 'No input file given' unless file abort "#{file}: No such path" unless File.exists?(file) @input = open(file).read - @user = ENV['HASTE_USER'] - @password = ENV['HASTE_PWD'] else @input = STDIN.readlines.join end @@ -28,16 +26,12 @@ module Haste # Upload the and output the URL we get back def start uri = URI.parse server - post = Net::HTTP::Post.new '/documents' - post.body = @input - post.basic_auth @user, @password if @user && @password - response = Net::HTTP.new(uri.host, uri.port).start do |http| - if uri.scheme =~ /^https/ - http.use_ssl = true - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - end - http.request(post) + http = Net::HTTP.new uri.host, uri.port + if uri.scheme =~ /^https/ + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE end + response = http.post '/documents', @input if response.is_a?(Net::HTTPOK) data = JSON.parse(response.body) method = STDOUT.tty? ? :puts : :print