Hi.

The attached patch to LWP::Protocol::nntp tries to add partial support
for the refbygroup-part of the URI::news definition of a newsURL.

Currently LWP::Protocol::nntp only supports news:messageid; the patch
adds support for news:group/number - it does not try to add support
for the news:group/fromnumber-tonumber variation.

Works for me; comments welcome.


  Best regards,

   Adam

-- 
 "My baby is my sun                                           Adam Sjøgren
  Not the burning one"                                   [EMAIL PROTECTED]



--- nntp.pm.orig        Fri Jan 16 12:05:28 2004
+++ nntp.pm     Fri Jan 16 12:48:06 2004
@@ -48,8 +48,9 @@
     }
 
     # extract the identifier and check against posting to an article
-    my $groupart = $url->_group;
-    my $is_art = $groupart =~ /@/;
+    my ($group, $artnum) = $url->_group;
+    my $groupart = $group;
+    my $is_art = ($groupart =~ /@/ or defined $artnum);
 
     if ($is_art && $method eq 'POST') {
        return HTTP::Response->new(&HTTP::Status::RC_BAD_REQUEST,
@@ -89,7 +90,7 @@
 
     # The method must be "GET" or "HEAD" by now
     if (!$is_art) {
-       if (!$nntp->group($groupart)) {
+       if (!$nntp->group($group)) {
            return HTTP::Response->new(&HTTP::Status::RC_NOT_FOUND,
                                       $nntp->message);
        }
@@ -99,7 +100,18 @@
 
     # Send command to server to retrieve an article (or just the headers)
     my $get = $method eq 'HEAD' ? "head" : "article";
-    my $art = $nntp->$get("<$groupart>");
+    my $art;
+    if (defined $artnum) {
+        if (!$nntp->group($group)) {
+           return HTTP::Response->new(&HTTP::Status::RC_NOT_FOUND,
+                                      $nntp->message);
+        }
+        $art = $nntp->$get($artnum);
+    }
+    else {
+        $art = $nntp->$get("<$groupart>");
+    }
+
     unless ($art) {
        return HTTP::Response->new(&HTTP::Status::RC_NOT_FOUND,
                                   $nntp->message);

Reply via email to