… | |
… | |
241 | } |
241 | } |
242 | |
242 | |
243 | substr $_, 0, 1, "" |
243 | substr $_, 0, 1, "" |
244 | for values %hdr; |
244 | for values %hdr; |
245 | |
245 | |
246 | if ($method ne "HEAD") { |
246 | if ($method eq "HEAD") { |
|
|
247 | %state = (); |
|
|
248 | $cb->(undef, \%hdr); |
|
|
249 | } else { |
247 | if (exists $hdr{"content-length"}) { |
250 | if (exists $hdr{"content-length"}) { |
248 | $_[0]->unshift_read (chunk => $hdr{"content-length"}, sub { |
251 | $_[0]->unshift_read (chunk => $hdr{"content-length"}, sub { |
249 | # could cache persistent connection now |
252 | # could cache persistent connection now |
250 | if ($hdr{connection} =~ /\bkeep-alive\b/i) { |
253 | if ($hdr{connection} =~ /\bkeep-alive\b/i) { |
251 | # but we don't, due to misdesigns, this is annoyingly complex |
254 | # but we don't, due to misdesigns, this is annoyingly complex |
… | |
… | |
277 | sub http_get($$;@) { |
280 | sub http_get($$;@) { |
278 | unshift @_, "GET"; |
281 | unshift @_, "GET"; |
279 | &http_request |
282 | &http_request |
280 | } |
283 | } |
281 | |
284 | |
|
|
285 | sub http_head($$;@) { |
|
|
286 | unshift @_, "HEAD"; |
|
|
287 | &http_request |
|
|
288 | } |
|
|
289 | |
282 | sub http_post($$$;@) { |
290 | sub http_post($$$;@) { |
283 | unshift @_, "POST", "body"; |
291 | unshift @_, "POST", "body"; |
284 | &http_request |
292 | &http_request |
285 | } |
293 | } |
286 | |
294 | |