Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from SetupRu/master

Last updates
  • Loading branch information...
commit 886e4fef64a6095ebe03ea1ac37f07b4ce3f764f 2 parents d29234a + 2b29e71
@dionys authored
View
4 MANIFEST
@@ -3,3 +3,7 @@ lib/MojoX/Transaction/WebSocket76.pm
MANIFEST
MANIFEST.SKIP
README
+t/00-load.t
+t/01-pod.t
+t/02-pod-coverage.t
+t/03-manifest.t
View
32 Makefile.PL
@@ -0,0 +1,32 @@
+#!/usr/bin/env perl
+
+use 5.006;
+use strict;
+use warnings;
+
+use ExtUtils::MakeMaker;
+
+
+WriteMakefile(
+ NAME => 'MojoX::Transaction::WebSocket76',
+ AUTHOR => 'Denis Ibaev <dionys@cpan.org>',
+ VERSION_FROM => 'lib/MojoX/Transaction/WebSocket76.pm',
+ ABSTRACT_FROM => 'lib/MojoX/Transaction/WebSocket76.pm',
+ LICENSE => 'perl',
+ META_MERGE => {
+ requires => {perl => '5.010001'},
+ resources => {
+ license => 'http://dev.perl.org/licenses/',
+ repository => 'http://github.com/dionys/mojox-transaction-websocket76',
+ bugtracker => 'http://github.com/dionys/mojox-transaction-websocket76/issues',
+ },
+ no_index => {directory => ['t']},
+ },
+ PREREQ_PM => {
+ 'Mojolicious' => '2.52',
+ 'Test::More' => 0,
+ },
+ dist => {COMPRESS => 'gzip -9f', SUFFIX => 'gz'},
+ clean => {FILES => 'MojoX-Transaction-WebSocket76-*'},
+ test => {TESTS => 't/*.t'},
+);
View
119 lib/MojoX/Transaction/WebSocket76.pm
@@ -31,7 +31,7 @@ sub build_frame {
warn('BYTES: ', $bytes, "\n");
}
else {
- warn("NOTHING\n")
+ warn("NOTHING\n")
}
}
@@ -61,7 +61,7 @@ sub parse_frame {
warn('BYTES: ', $bytes, "\n");
}
else {
- warn("NOTHING\n")
+ warn("NOTHING\n")
}
}
@@ -140,3 +140,118 @@ sub fix_headers {
1;
+
+
+__END__
+
+=head1 NAME
+
+MojoX::Transaction::WebSocket76 - WebSocket version hixie-76 transaction
+container
+
+=head1 SYNOPSIS
+
+ use MojoX::Transaction::WebSocket76;
+
+ my $ws = MojoX::Transaction::WebSocket76->new;
+
+=head1 DESCRIPTION
+
+MojoX::Transaction::WebSocket76 is a container for WebSocket transactions as
+described in L<hixie-76 draft|http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76>.
+Support for this version of the protocol was removed in L<Mojolicious> 1.17. But
+last version of the Safari browser (5.0.1) supports only it.
+
+To support for both versions of the protocol (last and hixie-76 draft) in your
+Mojolicious application, add:
+
+ # In application module.
+ package MyApp;
+
+ # Override Mojolicious::build_tx().
+ sub build_tx {
+ my ($self) = @_;
+ # Use your own transaction module.
+ my $tx = MyApp::Transaction->new;
+ $self->plugins->emit_hook(after_build_tx => $tx, $self);
+ return $tx;
+ }
+
+ # In transaction module.
+ package MyApp::Transaction;
+
+ use Mojo::Transaction::WebSocket;
+ use MojoX::Transaction::WebSocket76;
+
+ use Mojo::Base 'Mojo::Transaction::HTTP';
+
+ # Override Mojo::Transaction::HTTP::server_read().
+ sub server_read {
+ # ...
+ # Need to change only this piece of code.
+ if (lc($req->headers->upgrade || '') eq 'websocket') {
+ # Upgrade to WebSocket of needed version.
+ $self->emit(upgrade =>
+ ($req->headers->header('Sec-WebSocket-Key1')
+ && $req->headers->header('Sec-WebSocket-Key2'))
+ ? MojoX::Transaction::WebSocket76->new(handshake => $self)
+ : Mojo::Transaction::WebSocket->new(handshake => $self)
+ );
+ }
+ # ...
+ }
+
+=head1 EVENTS
+
+MojoX::Transaction::WebSocket76 inherits all events from
+L<Mojo::Transaction::WebSocket>.
+
+=head1 ATTRIBUTES
+
+MojoX::Transaction::WebSocket76 inherits all attributes from
+L<Mojo::Transaction::WebSocket>.
+
+=head1 METHODS
+
+MojoX::Transaction::WebSocket76 inherits all methods from
+L<Mojo::Transaction::WebSocket>.
+
+=head1 DEBUGGING
+
+You can set the C<MOJO_WEBSOCKET_DEBUG> environment variable to get some
+advanced diagnostics information printed to STDERR.
+
+ MOJO_WEBSOCKET_DEBUG=1
+
+=head1 SEE ALSO
+
+L<Mojolicious>, L<Mojo::Transaction::WebSocket>.
+
+=head1 SUPPORT
+
+=over 4
+
+=item Repository
+
+L<http://github.com/dionys/mojox-transaction-websocket76>
+
+=item Bug tracker
+
+L<http://github.com/dionys/mojox-transaction-websocket76/issues>
+
+=back
+
+=head1 AUTHOR
+
+Denis Ibaev, C<dionys@cpan.org>.
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2012, Denis Ibaev.
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+See L<http://dev.perl.org/licenses/> for more information.
+
+=cut
View
13 t/00-use.t
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+
+BEGIN {
+ use_ok('MojoX::Transaction::WebSocket76') or print("Bail out!\n");
+}
+
+diag("Testing MojoX::Transaction::WebSocket76 $MojoX::Transaction::WebSocket76::VERSION, Perl $], $^X");
View
14 t/01-pod.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl -T
+
+use strict;
+use warnings;
+
+use Test::More;
+
+
+plan(skip_all => 'Test::Pod 1.14 required for this test')
+ unless eval('use Test::Pod 1.14; 1');
+plan(skip_all => 'Set TEST_POD to enable this test (developer only)')
+ unless $ENV{TEST_POD};
+
+all_pod_files_ok();
View
16 t/02-pod-coverage.t
@@ -0,0 +1,16 @@
+#!/usr/bin/perl -T
+
+use strict;
+use warnings;
+
+use Test::More;
+
+
+plan(skip_all => 'Test::Pod::Coverage 1.04 required for this test')
+ unless eval('use Test::Pod::Coverage 1.04; 1');
+plan(skip_all => 'Pod::Coverage 0.18 required for this test')
+ unless eval('use Pod::Coverage 0.18; 1');
+plan(skip_all => 'Set TEST_POD to enable this test (developer only)')
+ unless $ENV{TEST_POD};
+
+all_pod_coverage_ok();
View
14 t/03-manifest.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl -T
+
+use strict;
+use warnings;
+
+use Test::More;
+
+
+plan(skip_all => 'Author tests not required for installation')
+ unless $ENV{RELEASE_TESTING};
+plan(skip_all => 'Test::CheckManifest 0.9 required for this test')
+ unless eval('use Test::CheckManifest 0.9; 1');
+
+ok_manifest();
Please sign in to comment.
Something went wrong with that request. Please try again.