Atompub::Server(3pm)
π Atompub::Server β a server for the Atom Publishing Protocol π
okay so bestie, this page lives in the User Contributed Perl Documentation section of your man pages, and it's about Atompub::Server, a lil base class that does the whole Atom Publishing Protocol server thing for you. π¦
β¨ NAME β¨
Atompub::Server β a server for the Atom Publishing Protocol, no cap.
πΈ SYNOPSIS πΈ
here's the vibe, exactly as written:
package My::Server;
use base qw(Atompub::Server);
sub handle_request {
my($server) = @_;
$server->authenticate or return;
my $method = $server->request_method;
if ($method eq 'POST') {
return $server->new_post;
}
...
}
my %Passwords;
sub password_for_user {
my($server, $username) = @_;
$Passwords{$username};
}
sub new_post {
my($server) = @_;
my $entry = $server->atom_body or return;
# $entry is an XML::Atom::Entry object.
# ... Save the new entry ...
}
package main;
my $server = My::Server->new;
$server->run;
periodt. that's the whole glow-up arc: subclass it, sub in your own logic, run it. π
π DESCRIPTION π
Atompub::Server gives you a base class for Atom Publishing Protocol servers. it handles all the core server processing, plus Basic and WSSE authentication. and the way it can run as either a mod_perl handler or as part of a CGI program? versatile icon behavior. π
here's the thing though β it does not give you functions specific to any particular implementation, like creating an entry, retrieving a list of entries, deleting an entry, etc. nope! implementations are supposed to subclass Atompub::Server, override the handle_request method, and handle all functions like that themselves. it's giving "you're the main character, i'm just the stage." π
Atompub::Server extends XML::Atom::Server, and basically provides the same functions. however, this module has been fixed based on the Atom Publishing Protocol described at <http://www.ietf.org/rfc/rfc5023.txt>, and it supports Basic authentication rather than WSSE.
π¦ SUBCLASSING π¦
π Request Handling π
subclasses of Atompub::Server must override the handle_request method to perform all request processing, fr fr. the implementation must set all response headers β including the response code and any relevant HTTP headers β and should return a scalar representing the response body to be sent back to the client.
for example:
sub handle_request {
my($server) = @_;
my $method = $server->request_method;
if ($method eq 'POST') {
return $server->new_post;
}
# ... handle GET, PUT, etc
}
sub new_post {
my($server) = @_;
my $entry = $server->atom_body or return;
# Implementation-specific
my $id = save_this_entry($entry);
my $location = join '/', $server->uri, $id;
my $etag = calc_etag($entry);
$server->response_header(Location => $location);
$server->response_header(ETag => $etag );
$server->response_code(RC_CREATED);
$server->response_content_type('application/atom+xml;type=entry');
# Implementation-specific
return serialize_entry($entry);
}
π Authentication π
servers that require authentication should override the password_for_user method. given a username (from the Authorization or WSSE header), password_for_user should return that user's password in plaintext. if the supplied username doesn't exist in your user database or alike, just return undef. simple as that. π«Ά
for example:
my %Passwords = (foo => 'bar'); # The password for "foo" is "bar".
sub password_for_user {
my($server, $username) = @_;
$Passwords{$username};
}
π₯ Basic Authentication π₯
realm must be assigned before authentication for Basic authentication. no realm, no service, bestie.
$server->realm('MySite');
if your server runs as a CGI program and authenticates by Basic authenticate, you should use the authentication mechanism of the http server, like .htaccess. let the http server handle that part, iykyk. β¨
π WSSE Authentication π
any pre-configuration is not required for WSSE. the password returned from password_for_user will be combined with the nonce and the creation time to generate the digest, which will be compared with the digest sent in the WSSE header. cryptographic slay. π
β METHODS β
Atompub::Server provides a variety of methods to be used by subclasses for retrieving headers, content, and other request information, and for setting the same on the response. a whole toolkit. π
$server->realm
if called with an argument, sets the realm for Basic authentication.
returns the current realm that will be used when receiving requests.
the rest of the little guys π
$server->send_http_header($content_type)$server->get_auth_info$server->authenticate$server->auth_failure($status, $message)- oether methods
descriptions are found in XML::Atom::Server. (and yes, the manpage literally says oether, we're leaving that exactly as-is, it's iconic in its own way π)
π USAGE π
once you have defined your server subclass, you can set it up either as a CGI program or as a mod_perl handler.
see XML::Atom::Server in details. π
πΈ SEE ALSO πΈ
XML::AtomXML::Atom::ServiceAtompubCatalyst::Controller::Atompub
π AUTHOR π
Takeru INOUE, <takeru.inoue _ gmail.com>
π LICENCE AND COPYRIGHT π
Copyright (c) 2007, Takeru INOUE "<takeru.inoue _ gmail.com>". All rights reserved.
this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. see perlartistic.
π DISCLAIMER OF WARRANTY π
bestie. take a deep breath. this part is in ALL CAPS for a reason.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
no warranty, no cap. π read it, internalize it, then go build your server anyway.
and that's the whole page bestie!! π this one came from perl v5.40.1, dated 2025-08-14, filed under Atompub::Server(3pm) β go forth and subclass, you've absolutely got this. πβ¨π«Ά
π¦ where this page comes from
- ubuntu resolute: libatompub-perl 0.3.7-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libatompub-perl 0.3.7-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms