~ubuntu-branches/ubuntu/wily/libwww-perl/wily

« back to all changes in this revision

Viewing changes to lib/LWP/Protocol/http10.pm

  • Committer: Bazaar Package Importer
  • Author(s): Antonio Radici, Antonio Radici, gregor herrmann
  • Date: 2009-02-27 23:41:21 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090227234121-j82kazqk5lmg6t4b
Tags: 5.825-1
[ Antonio Radici ]
* New upstream release
* debian/control:
  + Adding me to the Uploaders
  + removing duplicate 'priority' and 'section' from the binary package
  + added quilt dependency
  + bumped dependency to debhelper 7
* debian/compat:
  + bumped to 7
* debian/rules:
  + refreshed with dh-make-perl --dh 7
  + added quilt directives
* debian/README.source
  + added as per Debian Policy
* debian/patches/fix_no_proxy_desc.patch:
  + fix some erorrs in the description of no_proxy() on LWP::UserAgent 
  + bug already forwarded upstream (Closes: #277970)
* debian/patches/fix_ua_ssl_deps.patch:
  + fix the error message when some perl modules are not installed 
    to support HTTPS
  + bug already forwarded upstream (Closes: #500186)

[ gregor herrmann ]
* debian/control: Changed: Switched Vcs-Browser field to ViewSVN
  (source stanza).
* debian/control: Added: ${misc:Depends} to Depends: field.
* debian/copyright: update years of upstream copyright.
* debian/control: add libcrypt-ssleay-perl as an alternative suggestion
  to libio-socket-ssl-perl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
use strict;
4
4
 
5
 
require LWP::Debug;
6
5
require HTTP::Response;
7
6
require HTTP::Status;
8
7
require IO::Socket;
92
91
sub request
93
92
{
94
93
    my($self, $request, $proxy, $arg, $size, $timeout) = @_;
95
 
    LWP::Debug::trace('()');
96
94
 
97
95
    $size ||= 4096;
98
96
 
165
163
        die $! unless defined($n);
166
164
        $offset += $n;
167
165
    }
168
 
    LWP::Debug::conns($buf);
169
166
 
170
167
    if ($ctype eq 'CODE') {
171
168
        while ( ($buf = &$cont_ref()), defined($buf) && length($buf)) {
178
175
                die $! unless defined($n);
179
176
                $offset += $n;
180
177
            }
181
 
            LWP::Debug::conns($buf);
182
178
        }
183
179
    }
184
180
    elsif (defined($$cont_ref) && length($$cont_ref)) {
191
187
            die $! unless defined($n);
192
188
            $offset += $n;
193
189
        }
194
 
        LWP::Debug::conns($$cont_ref);
195
190
    }
196
191
 
197
192
    # read response line from server
198
 
    LWP::Debug::debug('reading response');
199
 
 
200
193
    my $response;
201
194
    $buf = '';
202
195
 
207
200
        $n = $socket->sysread($buf, $size, length($buf));
208
201
        die $! unless defined($n);
209
202
        die "unexpected EOF before status line seen" unless $n;
210
 
        LWP::Debug::conns($buf);
211
203
 
212
204
        if ($buf =~ s/^(HTTP\/\d+\.\d+)[ \t]+(\d+)[ \t]*([^\012]*)\012//) {
213
205
            # HTTP/1.0 response or better
214
206
            my($ver,$code,$msg) = ($1, $2, $3);
215
207
            $msg =~ s/\015$//;
216
 
            LWP::Debug::debug("$ver $code $msg");
217
208
            $response = HTTP::Response->new($code, $msg);
218
209
            $response->protocol($ver);
219
210
 
221
212
            # terminated by two blank lines
222
213
            until ($buf =~ /^\015?\012/ || $buf =~ /\015?\012\015?\012/) {
223
214
                # must read more if we can...
224
 
                LWP::Debug::debug("need more header data");
225
215
                die "read timeout" if $timeout && !$sel->can_read($timeout);
226
216
                my $old_len = length($buf);
227
217
                $n = $socket->sysread($buf, $size, $old_len);
228
218
                die $! unless defined($n);
229
219
                die "unexpected EOF before all headers seen" unless $n;
230
 
                LWP::Debug::conns(substr($buf, $old_len));
231
220
            }
232
221
 
233
222
            # now we start parsing the headers.  The strategy is to
262
251
        elsif ((length($buf) >= 5 and $buf !~ /^HTTP\//) or
263
252
               $buf =~ /\012/ ) {
264
253
            # HTTP/0.9 or worse
265
 
            LWP::Debug::debug("HTTP/0.9 assume OK");
266
254
            $response = HTTP::Response->new(&HTTP::Status::RC_OK, "OK");
267
255
            $response->protocol('HTTP/0.9');
268
256
            last;
270
258
        }
271
259
        else {
272
260
            # need more data
273
 
            LWP::Debug::debug("need more status line data");
274
261
        }
275
262
    };
276
263
    $response->request($request);
291
278
        die "read timeout" if $timeout && !$sel->can_read($timeout);
292
279
        my $n = $socket->sysread($buf, $size);
293
280
        die $! unless defined($n);
294
 
        #LWP::Debug::conns($buf);
295
281
        return \$buf;
296
282
        } );
297
283