Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing content in new frame after \n\n. patch provided [rt.cpan.org #124327] #16

Open
oalders opened this issue Apr 1, 2019 · 0 comments

Comments

@oalders
Copy link
Member

oalders commented Apr 1, 2019

Migrated from rt.cpan.org#124327 (status was 'new')

Requestors:

From doug@jshfarms.com on 2018-02-05 16:03:58
:

If the content of a post arrives in a new frame after the double return
_sometimes_ the sysread will miss it. I don't know if this is a time
related issue or not but it happens frequently while using Axios.

To mitigate this I am checking for 'Content-Length' in the header and if it
exists, verifying that length after the double return.
The following patch implements this.

# diff -c3 /home/breshead/Downloads/Daemon.pm Daemon.pm
*** /home/breshead/Downloads/Daemon.pm 2012-02-18 04:21:23.000000000 -0800
--- Daemon.pm 2018-02-05 07:58:16.278661220 -0800
***************
*** 116,123 ****
  $buf =~ s/^(?:\015?\012)+//;  # ignore leading blank lines
  if ($buf =~ /\012/) {  # potential, has at least one line
      if ($buf =~ /^\w+[^\012]+HTTP\/\d+\.\d+\015?\012/) {
! if ($buf =~ /\015?\012\015?\012/) {
!     last READ_HEADER;  # we have it
  }
  elsif (length($buf) > 16*1024) {
      $self->send_error(413); # REQUEST_ENTITY_TOO_LARGE
--- 116,135 ----
  $buf =~ s/^(?:\015?\012)+//;  # ignore leading blank lines
  if ($buf =~ /\012/) {  # potential, has at least one line
      if ($buf =~ /^\w+[^\012]+HTTP\/\d+\.\d+\015?\012/) {
!     if ($buf =~ /\015?\012\015?\012(.*)/) {
!             # It is possible for the data to follow the double
!             # return in the next frame, especially with axios for some
reason.
!             # So if the content length exists then check it and
_need_more() as needed.
!             my $content = $1;
!             my $content_len = length($content);
!             if ($buf =~ /Content-Length:\s*(\d+)/){
!                 my $advertised_len = $1;
!                 if ($content_len >= $advertised_len){
!                     last READ_HEADER;  # we have it
!                 }
!             }else{
!                 last READ_HEADER;  # we have it
!             }
  }
  elsif (length($buf) > 16*1024) {
      $self->send_error(413); # REQUEST_ENTITY_TOO_LARGE

-- 
Doug Breshears
JSH Farms Inc.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant