Changeset 172
- Timestamp:
- 02/20/08 21:19:04 (6 months ago)
- Files:
-
- 3 modified
-
COPYING (modified) (1 diff)
-
lib/atom/http.rb (modified) (8 diffs)
-
lib/atom/service.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
COPYING
r60 r172 7 7 sell copies of the Software, and to permit persons to whom the Software is 8 8 furnished to do so, subject to the following conditions: 9 9 10 10 The above copyright notice and this permission notice shall be included in 11 11 all copies or substantial portions of the Software. 12 12 13 13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 16 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 17 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 18 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -
lib/atom/http.rb
r171 r172 69 69 else 70 70 @@nonce_count += 1 71 nc = ('%08x' % @@nonce_count) 71 nc = ('%08x' % @@nonce_count) 72 72 73 73 # XXX auth-int … … 78 78 79 79 header = %Q<Digest username="#{user}", uri="#{req.path}", realm="#{params[:realm]}", response="#{response}", nonce="#{params[:nonce]}"> 80 80 81 81 if params[:opaque] 82 82 header += %Q<, opaque="#{params[:opaque]}"> … … 108 108 # This object can be used on its own, or passed to an Atom::Service, 109 109 # Atom::Collection or Atom::Feed, where it will be used for requests. 110 # 110 # 111 111 # All its HTTP methods return a Net::HTTPResponse 112 112 class HTTP … … 119 119 attr_accessor :token 120 120 121 # when set to :basic, :wsse or :authsub, this will send an 122 # Authentication header with every request instead of waiting for a 123 # challenge from the server. 124 # 121 # when set to :basic, :wsse or :authsub, this will send an 122 # Authentication header with every request instead of waiting for a 123 # challenge from the server. 124 # 125 125 # be careful; always_auth :basic will send your username and 126 126 # password in plain text to every URL this object requests. 127 127 # 128 # :digest won't work, since Digest authentication requires an 128 # :digest won't work, since Digest authentication requires an 129 129 # initial challenge to generate a response 130 130 # … … 250 250 251 251 digest = [Digest::SHA1.digest(nonce + now + pass)].pack("m").chomp 252 252 253 253 req['X-WSSE'] = %Q<UsernameToken Username="#{user}", PasswordDigest="#{digest}", Nonce="#{nonce_enc}", Created="#{now}"> 254 254 req["Authorization"] = 'WSSE profile="UsernameToken"' … … 305 305 306 306 req, url = new_request(url_s, method, headers) 307 307 308 308 # two reasons to authenticate; 309 309 if @always_auth … … 325 325 case res 326 326 when Net::HTTPUnauthorized 327 if @always_auth or www_authenticate or not res["WWW-Authenticate"] # XXX and not stale (Digest only) 327 if @always_auth or www_authenticate or not res["WWW-Authenticate"] # XXX and not stale (Digest only) 328 328 # we've tried the credentials you gave us once 329 329 # and failed, or the server gave us no way to fix it … … 362 362 res 363 363 end 364 364 365 365 def new_request(url_string, method, init_headers = {}) 366 366 headers = { "User-Agent" => UA }.merge(init_headers) 367 367 368 368 url = url_string.to_uri 369 369 370 370 rel = url.path 371 371 rel += "?" + url.query if url.query -
lib/atom/service.rb
r171 r172 209 209 210 210 unless atom 211 raise AutodiscoveryFailure "couldn't find an Atom link in the RSD"211 raise AutodiscoveryFailure, "couldn't find an Atom link in the RSD" 212 212 end 213 213
