Skip to content

Commit

Permalink
fixed typos
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 18, 2011
1 parent 0208cf3 commit 7c457c8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 27 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -12,6 +12,7 @@ This file documents the revision history for Perl extension Mojolicious.
- Fixed small redirect_to bug. (judofyr, sri)
- Fixed small attribute selector bug in Mojo::DOM::CSS.
- Fixed Perl 5.8.7 compatibility.
- Fixed typos.

1.98 2011-09-14 00:00:00
- Removed Mojo::Server::FastCGI so it can be maintained as a separate
Expand Down
30 changes: 7 additions & 23 deletions lib/Mojo/Transaction/WebSocket.pm
Expand Up @@ -90,7 +90,7 @@ sub build_frame {
sub client_challenge {
my $self = shift;

# WebSocket challenge
# Solve WebSocket challenge
my $solution = $self->_challenge($self->req->headers->sec_websocket_key);
return unless $solution eq $self->res->headers->sec_websocket_accept;
return 1;
Expand All @@ -109,7 +109,7 @@ sub client_handshake {
unless $headers->sec_websocket_protocol;
$headers->sec_websocket_version(13) unless $headers->sec_websocket_version;

# Generate challenge
# Generate WebSocket challenge
my $key = pack 'N*', int(rand 9999999);
b64_encode $key, '';
$headers->sec_websocket_key($key) unless $headers->sec_websocket_key;
Expand All @@ -123,13 +123,8 @@ sub connection { shift->handshake->connection(@_) }

sub finish {
my $self = shift;

# Send closing handshake
$self->_send_frame(CLOSE, '');

# Finish after writing
$self->{finished} = 1;

return $self;
}

Expand Down Expand Up @@ -239,7 +234,7 @@ sub send_message {
sub server_handshake {
my $self = shift;

# Handshake
# WebSocket handshake
my $res = $self->res;
my $res_headers = $res->headers;
$res->code(101);
Expand All @@ -258,19 +253,15 @@ sub server_handshake {
sub server_read {
my ($self, $chunk) = @_;

# Add chunk
# Parse frames
$self->{read} = '' unless defined $self->{read};
$self->{read} .= $chunk if defined $chunk;

# Full frames
$self->{message} = '' unless defined $self->{message};
while (my $frame = $self->parse_frame(\$self->{read})) {
my $op = $frame->[1] || CONTINUATION;

# Ping
if ($op == PING) {

# Pong
$self->_send_frame(PONG, $frame->[2]);
next;
}
Expand Down Expand Up @@ -320,6 +311,7 @@ sub server_write {
# Empty buffer
my $write = $self->{write};
$self->{write} = '';

return $write;
}

Expand All @@ -329,10 +321,8 @@ sub _challenge {
# No key or SHA1 support
return '' unless $key && SHA1;

# Checksum
# Base64 checksum
my $challenge = sha1_bytes($key . GUID);

# Accept
b64_encode $challenge, '';

return $challenge;
Expand All @@ -341,14 +331,10 @@ sub _challenge {
sub _send_frame {
my ($self, $op, $payload) = @_;

# Build frame
# Build frame and resume
$self->{write} = '' unless defined $self->{write};
$self->{write} .= $self->build_frame(1, $op, $payload);

# Writing
$self->{state} = 'write';

# Resume
$self->on_resume->($self);
}

Expand All @@ -357,8 +343,6 @@ sub _xor_mask {

# 512 byte mask
$mask = $mask x 128;

# Mask
my $output = '';
$output .= $_ ^ $mask while length($_ = substr($input, 0, 512, '')) == 512;
$output .= $_ ^ substr($mask, 0, length, '');
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Lite.pm
Expand Up @@ -672,7 +672,7 @@ directory.
=head2 Static Files
Static files will be automatically served from the C<DATA> section
(even Base 64 encoded) or a C<public> directory if it exists.
(even Base64 encoded) or a C<public> directory if it exists.
@@ something.js
alert('hello!');
Expand Down
6 changes: 3 additions & 3 deletions t/mojolicious/lite_app.t
Expand Up @@ -1004,13 +1004,13 @@ $t->get_ok('/static.txt', {'Range' => 'bytes=2-5'})->status_is(206)
->header_is('Accept-Ranges' => 'bytes')->header_is('Content-Length' => 4)
->content_is('st s');

# GET /static.txt (base 64 static inline file)
# GET /static.txt (base64 static inline file)
$t->get_ok('/static2.txt')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->header_is('Accept-Ranges' => 'bytes')->content_is("test 123\nlalala");

# GET /static.txt (base 64 static inline file, If-Modified-Since)
# GET /static.txt (base64 static inline file, If-Modified-Since)
$modified = Mojo::Date->new->epoch(time - 3600);
$t->get_ok('/static2.txt', {'If-Modified-Since' => $modified})->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
Expand All @@ -1021,7 +1021,7 @@ $t->get_ok('/static2.txt', {'If-Modified-Since' => $modified})->status_is(304)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')->content_is('');

# GET /static.txt (base 64 partial inline file)
# GET /static.txt (base64 partial inline file)
$t->get_ok('/static2.txt', {'Range' => 'bytes=2-5'})->status_is(206)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
Expand Down

0 comments on commit 7c457c8

Please sign in to comment.