Net::HTTP does not allow buffer size to be overridden in subclass [rt.cpan.org #25069]

オープン
#38 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
perl
領域
networking

調査の方向性

まず、Issue で説明されている 1024 バイトのハードコードされたサイズも含めて、my_readline() を経由する read_response_headers() と sysread() の呼び出しを追跡します。バッファサイズを設定できるようにするか、read_response_headers() を複製せずにサブクラスで読み取りヘルパーをきれいにオーバーライドできるようにすれば、作業は完了です。

索引モデルが issue の本文から書いたものです。

説明

Migrated from rt.cpan.org#25069 (status was 'open')

Requestors:

From [email protected] on 2007-02-21 22:00:19:

In Net::HTTP, read_response_headers() uses the function my_readline() to do it's dirty-work.  
Under the hood, my_readline() calls sysread() with a HARD-CODED size of 1024.  Ideally, this 
should be an option, or otherwise parameterized.  Alternately, it would make sense to 
replace my_readline() in a subclass, but this is impossible since it is called as a function.  One 
would need to replace read_response_headers() entirely in a subclass if one wanted to 
change the behavior here (to capture a larger buffer in the first read, cutting down on 
latency.) Alternately, one could redefine the my_readline() function.  The last two options are 
terrible designs, since they involve cloning the existing code and replacing only a small bit, 
and may result in future incompatibilities.

	    my $n = $self->sysread($_, 1024, length);

I suggest you expose or otherwise parameterize this currently hard-coded value.

Here is my current (nasty) workaround in a subclass:
package MyNetHTTP;
use base 'Net::HTTP';
sub my_sysread {
    my $self = shift;
    $_[1] = $READ_BUFFER_LENGTH;
    $self->SUPER::sysread(@_);
}

sub read_response_headers {
    my $self = shift;
    local *sysread = *my_sysread;
    $self->SUPER::read_response_headers( @_ );
}

From [email protected] on 2017-01-25 21:40:44:

migrated queues: libwww-perl -> Net-HTTP
主要言語
Perl
スター
20
フォーク
27
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

libwww-perl/Net-HTTP のほかの issue

libwww-perl/Net-HTTP の issue をすべて見る

似ている issue

Perl の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。