Skip to content

Commit 4b8e1e4

Browse files
committed
support PATCH HTTP method
1 parent 2e4cfcb commit 4b8e1e4

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/HTTP/Request.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ This constructs a new request object by parsing the given string.
185185
=item $r->method( $val )
186186
187187
This is used to get/set the method attribute. The method should be a
188-
short string like "GET", "HEAD", "PUT" or "POST".
188+
short string like "GET", "HEAD", "PUT", "PATCH" or "POST".
189189
190190
=item $r->uri
191191

lib/HTTP/Request/Common.pm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ our $DYNAMIC_FILE_UPLOAD ||= 0; # make it defined (don't know why)
77

88
use Exporter 5.57 'import';
99

10-
our @EXPORT =qw(GET HEAD PUT POST);
10+
our @EXPORT =qw(GET HEAD PUT PATCH POST);
1111
our @EXPORT_OK = qw($DYNAMIC_FILE_UPLOAD DELETE);
1212

1313
require HTTP::Request;
@@ -21,7 +21,7 @@ sub GET { _simple_req('GET', @_); }
2121
sub HEAD { _simple_req('HEAD', @_); }
2222
sub DELETE { _simple_req('DELETE', @_); }
2323

24-
for my $type (qw(PUT POST)) {
24+
for my $type (qw(PUT PATCH POST)) {
2525
no strict 'refs';
2626
*{ __PACKAGE__ . "::" . $type } = sub {
2727
return request_type_with_data($type, @_);
@@ -346,8 +346,8 @@ following call
346346
but is less cluttered. What is different is that a header named
347347
C<Content> will initialize the content part of the request instead of
348348
setting a header field. Note that GET requests should normally not
349-
have a content, so this hack makes more sense for the PUT() and POST()
350-
functions described below.
349+
have a content, so this hack makes more sense for the PUT(), PATCH()
350+
and POST() functions described below.
351351
352352
The get(...) method of C<LWP::UserAgent> exists as a shortcut for
353353
$ua->request(GET ...).
@@ -375,6 +375,14 @@ there is no way to directly specify a header that is actually called
375375
"Content". If you really need this you must update the request
376376
returned in a separate statement.
377377
378+
=item PATCH $url
379+
380+
=item PATCH $url, Header => Value,...
381+
382+
=item PATCH $url, Header => Value,..., Content => $content
383+
384+
Like PUT() but the method in the request is "PATCH".
385+
378386
=item DELETE $url
379387
380388
=item DELETE $url, Header => Value,...

0 commit comments

Comments
 (0)