Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

rfc5789 PATCH OPTIONS request/response

by Anonymous Monk
on Nov 05, 2012 at 10:51 UTC ( #1002305=CUFP: print w/ replies, xml ) Need Help??

http://tools.ietf.org/html/rfc5789
$ perl -MHTTP::Request::Common -e " my $f = HTTP::Request->parse ( qq{ +PATCH /file.txt HTTP/1.1\nHost: www.example.com\nC ontent-Type: application/example\nIf-Match: "e0023aa4e"\nContent-Lengt +h: 100\n\n[description of changes]} ); $f->dump " PATCH /file.txt HTTP/1.1 Host: www.example.com If-Match: e0023aa4e Content-Length: 100 Content-Type: application/example [description of changes]

#!/usr/bin/perl -- use strict; use warnings; use LWP; my $ua = LWP::UserAgent->new; $ua->show_progress(1); my $req = HTTP::Request->new( #~ OPTIONS => 'http://www.example.com/*', #~ OPTIONS => 'http://www.iana.org/domains/example/*', #~ OPTIONS => 'http://www.example.net/*', OPTIONS => 'http://www.example.de/*', ); $req->dump; my $res = $ua->request( $req ); $res->dump; __END__ OPTIONS http://www.example.de/* (no content) ** OPTIONS http://www.example.de/* ==> 200 OK (1s) HTTP/1.1 200 OK Connection: close Date: Mon, 05 Nov 2012 10:37:18 GMT Server: Apache Allow: GET,HEAD,POST,OPTIONS Content-Length: 0 Content-Type: text/plain Client-Date: Mon, 05 Nov 2012 10:40:35 GMT Client-Peer: 82.165.91.73:80 Client-Response-Num: 1 (no content)

#!/usr/bin/perl -- use strict; use warnings; use LWP; my $ua = LWP::UserAgent->new; $ua->show_progress(1); my $patch = q{ diff -ruN old/frobnicate new/frobnicate --- old/frobnicate 2012-11-05 02:43:25.453125000 -0800 +++ new/frobnicate 2012-11-05 02:43:32.625000000 -0800 @@ -1 +1 @@ -ECHO is on. +ECHO is off. }; use Digest::SHA(); my $etag = Digest::SHA::sha1_hex($patch); my $req = HTTP::Request->new( PATCH => 'http://www.example.de/frobnicate', HTTP::Headers->new( 'If-Match' => $etag, Content_Type => 'application/example', ), $patch, ); $req->dump; my $res = $ua->request( $req ); $res->dump; __END__ PATCH http://www.example.de/frobnicate If-Match: 3c7bd449ea9d806dd66f2da3f6535b020d9e0dd0 Content-Type: application/example diff -ruN old/frobnicate new/frobnicate --- old/frobnicate 2012-11-05 02:43:25.453125000 -0800 +++ new/frobnicate 2012-11-05 02:43:32.625000000 -0800 @@ -1 +1 @@ -ECHO is on. +ECHO is off.\n ** PATCH http://www.example.de/frobnicate ==> 405 Method Not Allowed ( +1s) HTTP/1.1 405 Method Not Allowed Connection: close Date: Mon, 05 Nov 2012 10:49:02 GMT Server: Apache Allow: GET,HEAD,POST,OPTIONS Content-Length: 233 Content-Type: text/html; charset=iso-8859-1 Client-Date: Mon, 05 Nov 2012 10:52:18 GMT Client-Peer: 82.165.91.73:80 Client-Response-Num: 1 Title: 405 Method Not Allowed <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>405 Method Not Allowed</title> </head><body> <h1>Method Not Allowed</h1> <p>The requested method PATCH is not allowed for the URL /frobnicate.< +/p> </body></html>\n

Comment on rfc5789 PATCH OPTIONS request/response
Select or Download Code
Re: rfc5789 PATCH OPTIONS request/response
by Corion (Pope) on Nov 05, 2012 at 12:37 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://1002305]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2015-07-07 08:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls