Coder Social home page Coder Social logo

net_dav's Introduction

NOTE: NO LONGER ACTIVELY MAINTAINED

Net::Dav library, in the style of Net::HTTP <img src=“https://travis-ci.org/devrandom/net_dav.svg?branch=master” alt=“Build Status” />

Install

Installing the gem:

gem install net_dav

and if you want acceleration for large files (from 4MB/s to 20MB/s in my setup):

gem install curb

If you’re having install issues with nokogiri on Mac OS X read wiki.github.com/tenderlove/nokogiri/what-to-do-if-libxml2-is-being-a-jerk

Usage

require 'net/dav'

Net::DAV.start("https://localhost.localdomain/xyz/") do |dav|
  dav.find('.', :recursive => true) do |item|
    item.content = item.content.gsub(/silly/i, 'funny')
  end
end

(Note that if you want to use “.” to refer to the origin URL, it should end with a slash, otherwise it is assumed that the last component is a file and “.” will refer to the parent.)

Documentation

RDoc: rdoc.info/projects/devrandom/net_dav Wiki: wiki.github.com/devrandom/net_dav

Performance

This should be threadsafe if you use a different Net::DAV object for each thread. Check out script/multi-test for a multi-threaded application.

Installing the curb gem will gain speedup with large files, but currently is much slower doing many small get operations. If your usecase is the latter and you have curb installed, you can disable its use by passing the

:curl => false

option to Net::DAV::start or Net::DAV::new .

Other

Thanks go to Thomas ( github.com/thomasfl/ ) and others for their help.

Thomas is writing the easy to use github.com/thomasfl/open-uri-and-write based on net_dav.

net_dav's People

Contributors

alicraigmile avatar as016194 avatar chumpy avatar devrandom avatar duffyjp avatar smortex avatar thomasfl avatar vivienbarousse avatar wdspkr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

net_dav's Issues

net_dav can put textfile only?

I want to put imagefile.
But I see raised error
ArgumentError: Content-Length not given and Transfer-Encoding is not `chunked'

4 specs are failing

4 of the specs are failing. I have changes that seem to fix them on my fork, and would be happy to submit a pull request once my pending pull request has been handled.

NameError in 'Net::Dav should write files to webdav server'
undefined local variable or method dav' for #<Spec::Example::ExampleGroup::Subclass_1:0x007f935451c9f0> spec/integration/net_dav_spec.rb:65:inblock (2 levels) in <top (required)>'

NameError in 'Net::Dav should delete files from webdav server'
undefined local variable or method dav' for #<Spec::Example::ExampleGroup::Subclass_1:0x007f93544dc9e0> spec/integration/net_dav_spec.rb:78:inblock (2 levels) in <top (required)>'

'Net::Dav should copy files on webdav server' FAILED
expected "404 "Not Found "" to match /200 OK/i
spec/integration/net_dav_spec.rb:87:in `block (2 levels) in <top (required)>'

'Net::Dav should move files on webdav server' FAILED
expected "404 "Not Found "" to match /200 OK/i
spec/integration/net_dav_spec.rb:103:in `block (2 levels) in <top (required)>'

Files are returned as directories for Depth: infinity requests

My WebDAV server (ownCloud) supports Depth: infinity PROPFIND requests which is much faster than specifying dav.find(..., recursive: true). However, for those requests items are returned as directories instead of files (i.e. every item.type == :directory).

result = []

Net::DAV.start(URL) do |dav|
  dav.credentials('user', 'secret')
  dav.headers('Depth' => 'infinity')

  dav.find(root) do |item|
    next unless item.type == :file

    result << item
  end
end

result

# => result is always empty

error retrieving file

if the uri to file is https://example.com/file.rb, the retrieval is successful
if the uri to file is https://example.com/foo/file.rb, the retrieval fails.
error log for file.content where file is of type Item:

Net::HTTPFatalError: 500 "Internal Server Error"
from /Users/zlu/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/http.rb:2295:in error!' from /Users/zlu/.rvm/gems/ruby-1.9.2-p0/gems/net_dav-0.5.0/lib/net/dav.rb:173:inhandle_request'
from /Users/zlu/.rvm/gems/ruby-1.9.2-p0/gems/net_dav-0.5.0/lib/net/dav.rb:104:in request_returning_body' from /Users/zlu/.rvm/gems/ruby-1.9.2-p0/gems/net_dav-0.5.0/lib/net/dav.rb:503:inget'
from /Users/zlu/.rvm/gems/ruby-1.9.2-p0/gems/net_dav-0.5.0/lib/net/dav/item.rb:35:in `content'
from (irb):37

Undefined local variable or method `response'

Hello, using the sample code from the wiki:

require 'rubygems'
require 'net/dav'

dav = Net::DAV.new(http://192.168.7.28:8085", :curl => false)
dav.verify_server = false
dav.credentials(ENV['DAVUSER'],ENV['DAVPASS'])

dav.find('.',:recursive=>true,:suppress_errors=>true,:filename=>/\.html|\.xml$/) do | item |
  puts "Checking: " + item.url.to_s
  if( item.content =~ /www.wrong.com/ )
    item.content = item.content.gsub("www.wrong.com", "www.right.com")
    puts "Updated: " + item.url.to_s
  end
end

I get this exception:

lib/net/dav.rb:162:in `handle_request': undefined local variable or method `response' for #<Net::DAV::NetHttpHandler:0x007fc07811b788> (NameError)
Did you mean?  response
	from /Users/mo/.rvm/gems/ruby-2.3.1/gems/net_dav-0.5.1/lib/net/dav.rb:192:in `handle_request'
	from /Users/mo/.rvm/gems/ruby-2.3.1/gems/net_dav-0.5.1/lib/net/dav.rb:150:in `request'
	from /Users/mo/.rvm/gems/ruby-2.3.1/gems/net_dav-0.5.1/lib/net/dav.rb:498:in `propfind'
	from /Users/mo/.rvm/gems/ruby-2.3.1/gems/net_dav-0.5.1/lib/net/dav.rb:531:in `find'
	from script.rb:8:in `<main>'

Indeed response is used here without being defined:
https://github.com/devrandom/net_dav/blob/master/lib/net/dav.rb#L162

`rake` fails with rspec >= 2.0

I'm using rspec 2.6.0. Running rake fails with the following message:

no such file to load -- spec/rake/spectask

Apparently, this file was deleted in rspec 2.0.

PROPDEL support

The propdel verb deletes properties. I can implement it myself the next couple of weeks.

Publish new release on rubygems

There have been many useful fixes since 0.5.0 published on Rubygems on March 12, 2010.
Could you bump version number and publish it?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.