diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-11-01 11:25:57 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-11-01 11:25:57 +0100 |
commit | 411282efdceeef47e1cf6205f00a31b71bca0e4a (patch) | |
tree | 09441c309366d7aba0c9fe983f8691007ddd149b /vespaclient | |
parent | 391302183f1042a379bb0f48432a75dad03c5867 (diff) |
Remove last traces of httpgateway
Diffstat (limited to 'vespaclient')
-rw-r--r-- | vespaclient/src/php/php_client.php | 112 | ||||
-rwxr-xr-x | vespaclient/src/ruby/ruby_client.rb | 130 |
2 files changed, 0 insertions, 242 deletions
diff --git a/vespaclient/src/php/php_client.php b/vespaclient/src/php/php_client.php deleted file mode 100644 index 95732f893a2..00000000000 --- a/vespaclient/src/php/php_client.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php - -# Client for putting or getting vespa documents. -# -# gunnarga@yahoo-inc.com -# september 2007 -# - -if ($argc < 2) { - echo "Usage: $argv[0] <url> [feedfile]\n"; - echo "\turl\t\tHttpGateway URL, e.g. http://myhost:myport/document/?abortondocumenterror=false\n"; - echo "\tfeedfile\tXML file to feed\n"; - exit(1); -} - -$url = $argv[1]; -$filename = $argv[2]; - -# split uri into subcomponents -$parsed_url = parse_url($url); -$hostname = $parsed_url['host']; -$port = $parsed_url['port']; -$path = $parsed_url['path']; -$query = $parsed_url['query']; - -$socket = stream_socket_client("{$hostname}:{$port}", $errno, $errstr, 30); - -if (file_exists($filename)) { - echo "* Parsing file {$filename}...\n"; - $feedfile = fopen($filename, "r"); - if ($feedfile) { - $fsize = filesize($filename); - $version = phpversion(); - $header = "POST {$path}?{$query} HTTP/1.1\r\n"; - $header .= "Host: {$hostname}:{$port}\r\n"; - $header .= "User-Agent: PHP/$version\r\n"; - $header .= "Content-Length: $fsize\r\n"; - $header .= "Content-Type: application/xml\r\n"; - $header .= "\r\n"; - - fwrite($socket, $header); - while (!feof($feedfile)) { - $buf = fgets($feedfile); - fwrite($socket, $buf); - } - fclose($feedfile); - } - -} else { - $version = phpversion(); - $header = "GET {$path}?{$query} HTTP/1.1\r\n"; - $header .= "Host: {$hostname}:{$port}\r\n"; - $header .= "User-Agent: PHP/$version\r\n"; - $header .= "\r\n"; - - fwrite($socket, $header); -} - -# check HTTP response -$firstline = fgets($socket); -if (!preg_match("/HTTP\/1.1 200 OK/", $firstline)) { - echo "HTTP gateway returned error message: $firstline"; -} - -# read rest of the HTTP headers -while (!feof($socket)) { - $line = fgets($socket); - if (preg_match("/Content-Length: (\d+)/", $line, $matches)) { - $content_length = $matches[1]; - } - if ($line == "\r\n") { - break; - } -} - -# collect xml data -$xmldata = stream_get_contents($socket, $content_length); - -# parse xml data -$xml = new SimpleXMLElement($xmldata); -foreach ($xml->error as $error) { - echo "Critical error: $error\n"; -} -foreach($xml->xpath("//messages/message") as $message) { - echo $message->asXML(); - echo "\n"; -} - -if (isset($xml->report->successes)) { - echo "\nSuccessful operations:"; - $ok_puts = $xml->report->successes["put"]; - $ok_updates = $xml->report->successes["update"]; - $ok_removes = $xml->report->successes["remove"]; - - if (isset($ok_puts)) { - echo " {$ok_puts} puts"; - } - if (isset($ok_updates)) { - echo " {$ok_updates} updates"; - } - if (isset($ok_removes)) { - echo " {$ok_removes} removes"; - } - echo "\n"; -} - -foreach($xml->xpath("/result/document") as $document) { - echo $document->asXML(); - echo "\n"; -} - -?> diff --git a/vespaclient/src/ruby/ruby_client.rb b/vespaclient/src/ruby/ruby_client.rb deleted file mode 100755 index 193ddbb3907..00000000000 --- a/vespaclient/src/ruby/ruby_client.rb +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env ruby -# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -require 'socket' -require 'uri' -require 'optparse' -require 'rexml/document' - -# Client for putting or getting vespa documents. The standard library -# routines for http requests are not used because they don't as per -# ruby 1.8.5 support streaming file transfer. -# -# gunnarga@yahoo-inc.com -# september 2007 -# -class RubyClient - include REXML - - CHUNKSIZE = 8192 - - def initialize(uri) - uri_components = URI.split(uri) - @hostname = uri_components[2] - @port = uri_components[3] - @path = uri_components[5] - @query = uri_components[7] - @socket = TCPSocket.new(@hostname, @port) - end - - def http_post(feedfile) - puts "* Parsing file #{feedfile}..." - fsize = File.stat(feedfile).size - header = "POST #{@path}?#{@query} HTTP/1.1\r\n" - header += "Host: #{@hostname}:#{@port}\r\n" - header += "User-Agent: Ruby/#{RUBY_VERSION}\r\n" - header += "Content-Length: #{fsize}\r\n" - header += "Content-Type: application/xml\r\n" - header += "\r\n" - - begin - @socket.print(header) - File.open(feedfile) do |file| - while buf = file.read(CHUNKSIZE) - @socket.print(buf) - end - end - rescue Exception => e - puts "Exception caught: #{e}" - end - - print_response - end - - def http_get - header = "GET #{@path}?#{@query} HTTP/1.1\r\n" - header += "Host: #{@hostname}:#{@port}\r\n" - header += "User-Agent: Ruby/#{RUBY_VERSION}\r\n" - header += "\r\n" - - begin - @socket.print(header) - rescue Exception => e - puts "Exception caught: #{e}" - end - - print_response - end - - def print_response - xmldata = "" - begin - firstline = @socket.gets - if not firstline =~ /HTTP\/1.1 200 OK/ - puts "HTTP gateway returned error message: #{firstline}" - end - while line = @socket.gets - if line =~ /Content-Length: (\d+)/ - content_length = $1.to_i - end - if line == "\r\n" - break - end - end - - xmldata = @socket.read(content_length) - rescue Exception => e - puts "Exception caught: #{e}" - end - - begin - xmldoc = Document.new(xmldata) - xmldoc.elements.each("/result/error") {|e| puts "Critical error: #{e.text}"} - xmldoc.elements.each("//messages/message") {|e| puts e.to_s} - successes = XPath.first(xmldoc, "//successes") - if (successes) - print "\nSuccessful operations:" - if (ok_puts = successes.attribute("put")) - puts " #{ok_puts} puts" - end - if (ok_updates = successes.attribute("update")) - puts " #{ok_updates} updates" - end - if (ok_removes = successes.attribute("remove")) - puts " #{ok_removes} removes" - end - end - xmldoc.elements.each("/result/document") {|e| puts e.to_s} - rescue Exception => e - puts "Exception caught: #{e}" - end - end - -end - -if ARGV.length < 1 - puts "Usage: #{$0} <url> [feedfile]\n"; - puts "\turl\t\tHttpGateway URL, e.g. http://myhost:myport/document/?abortondocumenterror=false"; - puts "\tfeedfile\tXML file to feed"; - exit 1 -end - -url = ARGV[0] -filename = ARGV[1] - -feeder = RubyClient.new(url) -if filename and File.exists?(filename) - feeder.http_post(filename) -else - feeder.http_get -end |