# Does webrick support the http PUT command?

**URL:** <https://www.ruby-forum.com/t/does-webrick-support-the-http-put-command/50776>\
**Category:** Ruby\
**Created:** [December 21, 2005, 1:28am UTC](https://www.ruby-forum.com/t/does-webrick-support-the-http-put-command/50776 "2005-12-21T01:28:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![acechase](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e95f7d/32.png) [@acechase](https://www.ruby-forum.com/u/acechase)\
**Post date:** [December 21, 2005, 1:28am UTC](https://www.ruby-forum.com/t/does-webrick-support-the-http-put-command/50776/1 "2005-12-21T01:28:46Z")

</div>

The subject line pretty much sums it up. I’m having trouble finding  
documentation on whether or not webrick supports the http 1.1 PUT  
command. Also, if the answer is yes, is it done in manner similar to  
Apache (with a server side script that handles the actual file copy)?

Thanks,  
Andrew

---

<div class="post-metadata">

**Author:** ![acechase](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e95f7d/32.png) [@acechase](https://www.ruby-forum.com/u/acechase)\
**Post date:** [December 21, 2005, 5:08am UTC](https://www.ruby-forum.com/t/does-webrick-support-the-http-put-command/50776/2 "2005-12-21T05:08:09Z")

</div>

On Wed, 21 Dec 2005 00:24:20 -0000, acechase [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The subject line pretty much sums it up. I’m having trouble finding  
> documentation on whether or not webrick supports the http 1.1 PUT  
> command. Also, if the answer is yes, is it done in manner similar to  
> Apache (with a server side script that handles the actual file copy)?

Apparently so (1), and apparently not (2):

===[server.rb]===  
require ‘webrick’

s = WEBrick::HTTPServer.new(:Port =\> 8086)

class PutServlet \< WEBrick::HTTPServlet::AbstractServlet  
def do\_PUT(req, res)

```
 # do what you like with the data here...

 res['Content-Type'] = "text/html"
 res.body = "Okay guv'nor, #{req.body} is 'put'..."

```

end  
end

s.mount(“/putter”, PutServlet)

trap(“INT”){ s.shutdown }  
s.start  
===[END]===

===[putter.rb]==  
require ‘net/http’

h = Net::HTTP.new(‘localhost’,8086)  
r = h.put(‘/putter’,‘A bit of the old data’)  
puts “And our server says: #{r.body}”  
===[END]===

===[OUTPUT]===  
And our server says: Okay guv’nor, A bit of the old data is ‘put’…  
===[END]===

So it’s handled however you want it to be…
