summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/http/webrick
Commit message (Collapse)AuthorAgeFilesLines
* Fixes #4863 (Missing "require 'webrick'" causes nondeterministic spec failures)Paul Berry2010-09-281-0/+1
| | | | Added a missing require to webrick/rest.rb.
* Code smell: Two space indentationMarkus Roberts2010-07-091-60/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
* Code smell: Avoid needless decorationsMarkus Roberts2010-07-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 704 occurances of (.*)\b([a-z_]+)\(\) with \1\2 3 Examples: The code: ctx = OpenSSL::SSL::SSLContext.new() becomes: ctx = OpenSSL::SSL::SSLContext.new The code: skip() becomes: skip The code: path = tempfile() becomes: path = tempfile * Replaced 31 occurances of ^( *)end *#.* with \1end 3 Examples: The code: becomes: The code: end # Dir.foreach becomes: end The code: end # def becomes: end
* Code smell: Line modifiers are preferred to one-line blocks.Markus Roberts2010-07-091-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 6 occurances of (while .*?) *do$ with The do is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: while line = f.gets do becomes: while line = f.gets The code: while line = shadow.gets do becomes: while line = shadow.gets The code: while wrapper = zeros.pop do becomes: while wrapper = zeros.pop * Replaced 19 occurances of ((if|unless) .*?) *then$ with The then is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then becomes: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } The code: unless defined?(@spec_command) then becomes: unless defined?(@spec_command) The code: if c == ?\n then becomes: if c == ?\n * Replaced 758 occurances of ((?:if|unless|while|until) .*) (.*) end with The one-line form is preferable provided: * The condition is not used to assign a variable * The body line is not already modified * The resulting line is not too long 3 Examples: The code: if Puppet.features.libshadow? has_feature :manages_passwords end becomes: has_feature :manages_passwords if Puppet.features.libshadow? The code: unless (defined?(@current_pool) and @current_pool) @current_pool = process_zpool_data(get_pool_data) end becomes: @current_pool = process_zpool_data(get_pool_data) unless (defined?(@current_pool) and @current_pool) The code: if Puppet[:trace] puts detail.backtrace end becomes: puts detail.backtrace if Puppet[:trace]
* Add master side file content streamingBrice Figureau2010-02-171-1/+6
| | | | | | | | | This patch allows the puppetmaster to serve file chunks by chunks without ever reading the file content in RAM. This allows serving large files directly with the master without impacting the master memory footprint. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix for #2600 (wrong number of arguments under older mongrel)Markus Roberts2009-09-151-5/+2
| | | | | | | | | | | | | | | | | | This was an API compatibility problem with mongrel's HTTPResponse.start() method between Mongrel 1.0.x and 1.1.x (the number of parameters changed). The older version does not provide the option to set the response header message which was used (redundantly with the response body) to return the error message when the HTTP response was signaling an error. In order to suport the older version the call was wrapped with a fallback and the coresponding code in the other rest implementations was adjusted to always send the error message in the response body. Then the rest terminus was adjusted to pull the message from the response body (if it is present) rather than from the header (which is only used as a fallback for dealing with older puppetmasters), and the tests were augmeted to verify this behaviour. Signed-off-by: Markus Roberts <Markus@reality.com>
* Fix #2392 - use Content-Type for REST communicationBrice Figureau2009-07-051-1/+5
| | | | | | | | | | | | | | | | | | | There were two problems: * server->client communications is using Content-Type with the direct format name instead of the format mime-type. * client->server communications is not using Content-Type to send the format of the serialized object. Instead it is using the first member of the Accept header. The Accept header is usually reserved for the other side, ie what the client will accept when the server will respond. This patch makes sure s->c communication contains correct Content-Type headers. This patch also adds a Content-Type header containing the mime-type of the object sent by the client when saving. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fill REST request node with reverse lookup of IP addressBrice Figureau2009-04-231-0/+3
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fixing #1557 - Environments are now in REST URIsLuke Kanies2009-03-201-7/+1
| | | | | | | | | | | | | | | | | | This commit includes multiple, related changes, all in one commit because the whole thing was necessary to reach a functional tree again: * The URI starts with the environment, so: /production/certificate/foo /development/file_content/path/to/your/file * All REST handling is done by a single instance mounted at / for webrick and Mongrel, rather than having individual instances mounted at, say, /certificate. * All REST URI translation is done by an API module. Currently only the 'v1' module exists with no support for additional modules, but it's well-separated and will be easy to expand as we need it. Signed-off-by: Luke Kanies <luke@madstop.com>
* Adding clarity to query string handling in REST callsLuke Kanies2009-02-181-0/+1
| | | | | | | | | | | | We previously only handled simple strings as values, but we know handle true and false as booleans, we URI-escape all strings, and we can yaml-encode and then escape arrays of strings. This could get abused a bit, in that we're just yaml-dumping anything that's an array, but it should be pretty safe. Mmmm, should. Signed-off-by: Luke Kanies <luke@madstop.com>
* Fixing the rest backends for webrick and mongrel so the get the whole ↵Luke Kanies2008-08-261-1/+1
| | | | | | | | | request key. Also adding the Content work necessary to demonstrate that this is actually required. Signed-off-by: Luke Kanies <luke@madstop.com>
* All error and format handling works over REST except searching.Luke Kanies2008-07-291-3/+7
| | | | | | | | | Searching operates on multiple instances, and I have not yet figured out how we should handle converting multiple instances to a given format -- we can't use the instance method (e.g., to_yaml), because it would be on Array instead of the class we're operating on. That would work for yaml, but not, for instance, for xml.
* Drastically simplifying the REST implementation tests.Luke Kanies2008-07-291-3/+10
| | | | | | | | | Nearly all of the tests are now written just once, in the Handler module. The Mongrel and Webrick tests just validate that they provide the interface and how they do so. Signed-off-by: Luke Kanies <luke@madstop.com>
* The mongrel and webrick REST handlers now extract certificate information.Luke Kanies2008-06-091-15/+36
| | | | | | | | | | | All requests should now have an ipaddress add to them, they should always be marked authenticated or not, and they should have the certificate name set as their 'node' if a certificate is present. They both use the same methods they use for xmlrpc, although there's no common code, to facilitate deprecation of xmlrpc.
* Much larger commit than I would like to land at once. This is all ↵Rick Bradley2008-04-111-8/+9
| | | | | | | | | | | | | | | | | | | | | REST-related code. Two specs are failing related to how Mongrel is initialized for REST; will fix those shortly. REST indirector now supports find, with deserialization. Network code in indirector now. Will still need to un-hardwire address/port for outbound connections. Will still need to urlencode path parameters. Code for search, destroy, update is coming, should be similar to find. Reworked how the Handler module is used. Needed to be included, rather than inherited. Needed to sidestep initializers for actual web servers (webrick, mongrel), needed to be possible to have handler-including class be used as a class (aka servlet) instead of as an instance. Webrick handler registration is now abstracted to "above" the servlet. Provided a #model method to use instead of @model in handler module. This allows neutering during testing. Brought class_for_protocol up into http/webrick class as a (tested) class method. Integration tests for rest indirection. Split server integration tests into mongrel and webrick tests. Got Node/REST working properly wrt the crazy-ass autoloader thing. We're now actually passing traffic w/ webrick, fwiw.
* This is the first version where mongrel and webrick are reliably startable ↵Rick Bradley2008-04-111-1/+3
| | | | | | | | | | | | | | | | and stoppable via Puppet::Network::Server. Added a network/server integration spec, testing startup, shutdown, reachability, and collision of webrick and mongrel servers in the new network code. Converted Puppet::Network::HTTP::Handler class to a module, as mongrel Handler should be subclassed; converting subclasses to include the module instead. Mongrel will actually stop if you .stop it, graceful_shutdown didn't seem quite so reliable. Webrick requires running in its own Thread to avoid hanging the entire process; this requires introduction of a Mutex to make things safe. We're only supporting the REST protocol. Made this explicit. Fixed http server setup args, w/ specs, ah the glory of integration testing.
* the indirector will not serve xmlrpc (this is the responsibility of the ↵Rick Bradley2008-04-111-4/+0
| | | | legacy networking code; it was a mistake to include stubbed support for it in the new code); removing
* Found all instances of methods where split() is used withoutLuke Kanies2008-03-211-3/+5
| | | | | | | | | | any local variables and added a local variable -- see http://snurl.com/21zf8. My own testing showed that this caused memory growth to level off at a reasonable level. Note that the link above says the problem is only with class methods, but my own testing showed that it's any method that meets these criteria. This is not a functional change, but should hopefully be the last nail in the coffin of #1131.
* Exceptions on requests are now captured, exceptions are serialized, and ↵Rick Bradley2007-10-231-2/+2
| | | | exception text is passed back via REST.
* Finish serializing successful results (via calls to to_yaml, etc.) for REST ↵Rick Bradley2007-10-231-0/+1
| | | | handlers. Refactor request building in REST handler specs.
* REST handlers now properly returning 200 status on success.Rick Bradley2007-10-231-1/+1
|
* More specs, fleshing out the returns from RESTRick Bradley2007-10-171-0/+4
|
* Argument passing now supported on {webrick,mongrel}+REST.Rick Bradley2007-10-161-0/+4
|
* Refactoring, argument processing for model methods.Rick Bradley2007-10-161-1/+9
|
* Tweak to move model lookup functionality into the Handler base class where ↵Rick Bradley2007-10-161-1/+0
| | | | it belongs. Robustifying the request sanitization a bit more.
* Refactored to use a Handler base class for server+protocol handlers. ↵Rick Bradley2007-10-161-8/+13
| | | | Finally eliminated dependency on Puppet.start, etc., from WEBrick HTTP server class. {webrick,mongrel}+REST now support request handling uniformly; need encode/decode next.
* Registration now built for {webrick,mongrel} REST handlers.Rick Bradley2007-10-161-2/+8
|
* Going back to each server+protocol object being responsible for only one ↵Rick Bradley2007-10-161-6/+2
| | | | indirection, as the REST vs. XMLRPC models are different enough that the object must register itself on initialization and handle the request when it comes in.
* First pass through initializers of {mongrel, webrick} REST handlers; hooks ↵Rick Bradley2007-10-161-0/+14
| | | | into Indirection to look up models from indirected names.
* Finish front end of delegation to server+protocol helper classes ("handlers").Rick Bradley2007-10-152-0/+8