view release on metacpan or search on metacpan
lib/HTTP/Engine/Middleware/Encode.pm view on Meta::CPAN
before_handle {
my ( $c, $self, $req ) = @_;
my $encoding = $self->decode;
if ($self->detected_decode_by_header) {
if (( $req->headers->header('content-type') || '' ) =~ /charset\s*=\s*([^\s]+);?$/ ) {
$encoding = $1;
}
}
# decode parameters
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Handy.pm view on Meta::CPAN
'REQUEST_METHOD' => $method,
'PATH_INFO' => $path,
'QUERY_STRING' => $query_string,
'SERVER_NAME' => $server_name,
'SERVER_PORT' => $env_port,
'CONTENT_TYPE' => $headers{'content-type'} || '',
'CONTENT_LENGTH' => $content_length,
'psgi.input' => $input,
'psgi.errors' => \*STDERR,
'psgi.url_scheme' => 'http',
);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Headers/ActionPack.pm view on Meta::CPAN
HTTP::Headers::ActionPack::WWWAuthenticate
];
my %DEFAULT_MAPPINGS = (
'link' => 'HTTP::Headers::ActionPack::LinkList',
'content-type' => 'HTTP::Headers::ActionPack::MediaType',
'accept' => 'HTTP::Headers::ActionPack::MediaTypeList',
'accept-charset' => 'HTTP::Headers::ActionPack::AcceptCharset',
'accept-encoding' => 'HTTP::Headers::ActionPack::PriorityList',
'accept-language' => 'HTTP::Headers::ActionPack::AcceptLanguage',
'date' => 'HTTP::Headers::ActionPack::DateHeader',
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Headers/Fancy.pm view on Meta::CPAN
version 1.001
=head1 SYNOPSIS
my %fancy = decode_hash('content-type' => ..., 'x-foo-bar-baf-baz' => ...);
my $content_type = $fancy{ContentType};
my $x_foo_bar_baf_baz = $fancy{-FooBarBafBaz};
my %headers = encode_hash(ContentType => ..., -foo_bar => ...);
# %headers = ('content-type' => ..., 'x-foo-bar' => ...);
=head1 DESCRIPTION
This module provides method for renaming HTTP header keys to a lightier, easier-to-use format.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Headers/Fast.pm view on Meta::CPAN
# relative seconds and a positive value for epoch based time values.
#sub retry_after { shift->_date_header('Retry-After', @_); }
sub content_type {
my $self = shift;
my $ct = $self->{'content-type'};
$self->{'content-type'} = shift if @_;
$ct = $ct->[0] if ref($ct) eq 'ARRAY';
return '' unless defined($ct) && length($ct);
my @ct = split( /;\s*/, $ct, 2 );
for ( $ct[0] ) {
s/\s+//g;
lib/HTTP/Headers/Fast.pm view on Meta::CPAN
wantarray ? @ct : $ct[0];
}
sub content_type_charset {
my $self = shift;
my $h = $self->{'content-type'};
$h = $h->[0] if ref($h);
$h = "" unless defined $h;
my @v = _split_header_words($h);
if (@v) {
my($ct, undef, %ct_param) = @{$v[0]};
view all matches for this distribution
view release on metacpan or search on metacpan
- Fixed lowercase header bugs
- Thanks goes to contributed patches by various people
2.1.5 2003-10-05
- Fixed duplicate my in method()
- Added default content-type for posts
- header_at_once mode, patch submitted by Roman Radaschutz
2.1.3 2002-02-10
- Documentation fixes
- Fixed large write bug in http_write
1.0.1 2002-06-11
- Changed default protocol to HTTP/1.0 and added a switch to
activate HTTP/1.1 protocol.
1.0.0 2002-01-08
- Fixed bug where content-type was always set to only set it has not
yet been set.
Thanks to Rui Miguel Seabra <rms@multicert.com>
- Fixed bug where file descriptors were not being released by
request()
Thanks to Ross Snyder" <ross@newgrounds.com>
view all matches for this distribution
view release on metacpan or search on metacpan
Keys (header names) are converted to lower case.
Example:
{
'content-type' => ['text/html; charset=iso-8859-1'],
'connection' => ['close'],
'date' => ['Sun, 04 Jul 2010 18:21:12 GMT'],
'content-length' => ['217'],
'allow' => ['GET,HEAD,POST,OPTIONS,TRACE'],
'server' => ['Apache'],
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Headers.pm view on Meta::CPAN
# relative seconds and a positive value for epoch based time values.
#sub retry_after { shift->_date_header('Retry-After', @_); }
sub content_type {
my $self = shift;
my $ct = $self->{'content-type'};
$self->{'content-type'} = shift if @_;
$ct = $ct->[0] if ref($ct) eq 'ARRAY';
return '' unless defined($ct) && length($ct);
my @ct = split(/;\s*/, $ct, 2);
for ($ct[0]) {
s/\s+//g;
lib/HTTP/Headers.pm view on Meta::CPAN
}
sub content_type_charset {
my $self = shift;
require HTTP::Headers::Util;
my $h = $self->{'content-type'};
$h = $h->[0] if ref($h);
$h = "" unless defined $h;
my @v = HTTP::Headers::Util::split_header_words($h);
if (@v) {
my($ct, undef, %ct_param) = @{$v[0]};
view all matches for this distribution
view release on metacpan or search on metacpan
t/04-header.t view on Meta::CPAN
'cseq' => '0009 INVITE',
'via' => 'SIP / 2.0 /UDP 192.0.2.2;branch=390skdjuw',
's' => '',
'newfangledheader' => 'newfangled value continued newfangled value',
'unknownheaderwithunusualvalue' => ';;,,;;,;',
'content-type' => 'application/sdp',
'route' => '<sip:services.example.com;lr;unknownwith=value;unknown-no-value>',
'v' => 'SIP / 2.0 / TCP spindle.example.com ; branch = z9hG4bK9ikj8 , SIP / 2.0 / UDP 192.168.255.111 ; branch= z9hG4bK30239',
'm' => '"Quoted string \"\"" <sip:jdrosen@example.com> ; newparam = newvalue ; secondparam ; q = 0.33',
];
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Negotiate.pm view on Meta::CPAN
# specific than "text/html", which is more specific than "text/*",
# which in turn is more specific than "*/*"). If not media range
# in the provided Accept field matches the variant's media type,
# then the value assigned is "q=0".
if (exists $accept{'type'} && $ct) {
# First we clean up our content-type
$ct =~ s/\s+//g;
my $params = "";
$params = $1 if $ct =~ s/;(.*)//;
my($type, $subtype) = split("/", $ct, 2);
my %param = ();
lib/HTTP/Negotiate.pm view on Meta::CPAN
next if $at_type ne '*' && $at_type ne $type;
next if $at_subtype ne '*' && $at_subtype ne $subtype;
my $specificness = 0;
$specificness++ if $at_type ne '*';
$specificness++ if $at_subtype ne '*';
# Let's see if content-type parameters also match
while (($pk, $pv) = each %param) {
print "Check if $pk = $pv is true\n" if $DEBUG;
next unless exists $accept{'type'}{$at}{$pk};
next ACCEPT_TYPE
unless $accept{'type'}{$at}{$pk} eq $pv;
lib/HTTP/Negotiate.pm view on Meta::CPAN
- an original piece of ASCII-art may degrade in quality if it is
captured in JPEG form. The qs values should be assigned to each
variant by the content provider; if no qs value has been assigned, the
default is generally "qs=1".
=item content-type
This is the media type of the variant. The media type does not
include a charset attribute, but might contain other parameters.
Examples are:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Parser/XS.pm view on Meta::CPAN
# $ret is the length of the headers, starting the content body
# the other values are the response messages. For example:
# $status = 200
# $message = "OK"
# $headers = [ 'content-type' => 'text/html', ... ]
# and $special_headers{'content-length'} will be filled in
}
view all matches for this distribution
view release on metacpan or search on metacpan
if($result) {
skip "Didn't get response object", 3;
} else {
my $res = $parser->object;
isa_ok($res, 'HTTP::Response');
is($res->header('content-type'), 'text/plain', 'content type is correct');
is($res->content, "Some content!\x0d\x0a", 'content is correct');
}
# <1>
$parser = HTTP::Parser->new(request => 1);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Parser2/XS.pm view on Meta::CPAN
} else {
# $rv contains the length of the response header on success
}
if (exists $r->{'content-type'} &&
$r->{'content-type'}->[0] eq 'text/html')
{
# ...
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Promise/Body/Form/Data.pm view on Meta::CPAN
Each key represents a C<form-data> field and its value can either be a simple string or a C<HTTP::Promise::Body::Form::Field> object.
C<multipart/form-data> is the only valid Content-Type for sending multiple data. L<rfc7578 in section 4.3|https://tools.ietf.org/html/rfc7578#section-4.3> states: "[RFC2388] suggested that multiple files for a single form field be transmitted using a...
See also this L<Stackoverflow discussion|https://stackoverflow.com/questions/36674161/http-multipart-form-data-multiple-files-in-one-input/41204533#41204533> and L<this one too|https://stackoverflow.com/questions/51575746/http-header-content-type-mul...
=head1 CONSTRUCTOR
=head2 new
view all matches for this distribution
view release on metacpan or search on metacpan
Filter: HTTP::Proxy::HeaderFilter::simple
* logger.pl
This filter outputs the important information out of GET and POST
requests: method, URI, cookies, content-type (text/*) and POST
request parameters.
Filter: HTTP::Proxy::HeaderFilter::simple
* adblock.pl
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Request/AsCurl.pm view on Meta::CPAN
my @data = split '&', $content;
my $method = $request->method;
my $uri = $request->uri;
my $headers = $request->headers;
my $user = $headers->authorization_basic;
my @h = grep { $_ !~ /(authorization|content-length|content-type)/i }
$headers->header_field_names;
my @cmd = (["curl"]);
push(@cmd, ["--request", $method, $uri]);
push(@cmd, ["--dump-header", "-"]);
view all matches for this distribution
view release on metacpan or search on metacpan
t/01_basic.t view on Meta::CPAN
hogehoge
----------
{
'_content' => "hogehoge\n",
'_protocol' => 'HTTP/1.0',
'_headers' => { "content-type" => "text/html"},
'_rc' => 200,
'_msg' => 'OK'
}
----------
HTTP/1.0 200 OK
t/01_basic.t view on Meta::CPAN
hogehoge
----------
{
'_content' => "hogehoge\n",
'_protocol' => 'HTTP/1.0',
'_headers' => { "content-type" => "text/html", "x-test" => [1,2]},
'_rc' => 200,
'_msg' => 'OK'
}
----------
HTTP/1.0 200 OK
t/01_basic.t view on Meta::CPAN
hogehoge
----------
{
'_content' => "hogehoge\n",
'_protocol' => 'HTTP/1.0',
'_headers' => { "content-type" => "text/html", "x-test" => "1\n X-Test: 2"},
'_rc' => 200,
'_msg' => 'OK'
}
----------
HTTP/1.0 200 OK
Content-Type: text/html
----------
{
'_content' => "",
'_protocol' => 'HTTP/1.0',
'_headers' => { "content-type" => "text/html"},
'_rc' => 200,
'_msg' => 'OK'
}
----------
HTTP/1.1 200 OK
Content-Type: text/html
----------
{
'_content' => "",
'_protocol' => 'HTTP/1.1',
'_headers' => { "content-type" => "text/html"},
'_rc' => 200,
'_msg' => 'OK'
}
----------
HTTP/1.1 404 Not Found
Content-Type: text/html
----------
{
'_content' => "",
'_protocol' => 'HTTP/1.1',
'_headers' => { "content-type" => "text/html"},
'_rc' => 404,
'_msg' => 'Not Found'
}
----------
HTTP/1.1 200 OK
t/01_basic.t view on Meta::CPAN
FOO_BAR: 42
----------
{
'_content' => "",
'_protocol' => 'HTTP/1.1',
'_headers' => { "content-type" => "text/html", "foo-bar" => 42},
'_rc' => 200,
'_msg' => 'OK'
}
__HEADERS
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/SecureHeaders.pm view on Meta::CPAN
# ALLOW-FROM # deprecated
}
# refs https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/CrossDomain_PolicyFile_Specification.pdf
sub check_x_permitted_cross_domain_policies {
$_[0] =~ m!\A(?:none|master-only|by-content-type|by-ftp-filename|all)\z!
}
# refs https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
sub check_x_xss_protection {
$_[0] eq '0' or
view all matches for this distribution
view release on metacpan or search on metacpan
- Switched to using IO::File for the file handling, also
turned on binmode to help those on Windows serve images, etc.
0.02 Wed Mar 29 12:00:00 2005
- close fh after reading content. (Max Maischein)
- fixed content-type header (Kang-min Liu & Max)
0.01 Thu Jan 06 21:40:02 2005
- forked from patch to HTTP::Server::Simple
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Session/State/Mixin/ResponseFilter.pm view on Meta::CPAN
}
$res->[1] = \@new_headers;
return $res;
} elsif (my $body = $res->[2]) {
if ( ref $body eq 'ARRAY' ) {
# TODO: look the content-type header.
my $content = '';
for my $line (@$body) {
$content .= $line if length $line;
}
$res->[2] = [$self->html_filter($session_id, $content)];
view all matches for this distribution
view release on metacpan or search on metacpan
- bring in changes from usage at Followerwonk (Chris Prather)
- add on_error handling and structured exceptions (Chris Prather)
- s/decode/decoded_content/ to match HTTP::Message (Chris Prather)
0.003 2013-02-18T23:43:47
- Fix it so that the content-type is set also with add_json (Chris
Prather)
0.002 2013-02-18T23:07:26
- Add a warning about API breakage (Chris Prather)
- split the API out a little (Chris Prather)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Throwable/Role/Status/RequestedRangeNotSatisfiable.pm view on Meta::CPAN
than the current length of the selected resource.)
When this status code is returned for a byte-range request, the
response SHOULD include a Content-Range entity-header field specifying
the current length of the selected resource. This response MUST NOT
use the multipart/byteranges content-type.
=head1 PERL VERSION
This library should run on perls released even a long time ago. It should work
on any version of perl released in the last five years.
lib/HTTP/Throwable/Role/Status/RequestedRangeNotSatisfiable.pm view on Meta::CPAN
#pod than the current length of the selected resource.)
#pod
#pod When this status code is returned for a byte-range request, the
#pod response SHOULD include a Content-Range entity-header field specifying
#pod the current length of the selected resource. This response MUST NOT
#pod use the multipart/byteranges content-type.
#pod
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Tiny/Bandwidth.pm view on Meta::CPAN
binmode $fh;
}
my $upload_limit_bps = $args->{upload_limit_bps};
$args->{content} = $self->_upload_data_callback($fh, $upload_limit_bps);
($args->{headers} ||= +{})->{'content-length'} = -s $fh;
# XXX set content-type via Plack::MIME?
}
my $set_bandwidth_data_callback;
my ($download_content, $download_content_fh);
if (my $download_limit_bps = $args->{download_limit_bps}) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Tiny/FileProtocol.pm view on Meta::CPAN
success => $success,
status => $status,
( !$success ? (reason => $reason) : () ),
content => $content // '',
headers => {
'content-type' => $content_type,
'content-length' => $bytes // 0,
},
};
return $response;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Tiny/Multipart.pm view on Meta::CPAN
}
# Add boundary to Content-Type header
my $before = 'multipart/form-data';
my $after = '';
if( defined $headers->{'content-type'} ) {
if( $headers->{'content-type'} =~ m!^(.*multipart/[^;]+)(.*)$! ) {
$before = $1;
$after = $2;
}
}
$headers->{'content-type'} = "$before; boundary=$boundary$after";
return "--$boundary\x0d\x0a";
}
sub _build_content {
view all matches for this distribution
view release on metacpan or search on metacpan
push @params, join("=", map { uri_escape_utf8($_) } @pair);
}
my $response = HTTP::Tiny->new->request('POST', $url, {
content => join("&", @params),
headers => { 'content-type' => 'application/x-www-form-urlencoded' }
});
print "$response->{status} $response->{reason}\n";
print $response->{content};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Tinyish/Base.pm view on Meta::CPAN
sub internal_error {
my($self, $url, $message) = @_;
return {
content => $message,
headers => { "content-length" => length($message), "content-type" => "text/plain" },
reason => "Internal Exception",
status => 599,
success => "",
url => $url,
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/WebTest/Plugin/SetRequest.pm view on Meta::CPAN
# set request method (with default GET)
if(defined $method) {
if($method =~ /^POST$/i) {
$request->method('POST');
# ensure correct default value for content-type header
$request->header(Content_Type =>
'application/x-www-form-urlencoded');
} else {
$request->method('GET');
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/XSHeaders.pm view on Meta::CPAN
HTTP::Date::str2time($old);
}
sub content_type {
my $self = shift;
my $ct = $self->header('content-type');
$self->header('content-type', shift) if @_;
$ct = $ct->[0] if ref($ct) eq 'ARRAY';
return '' unless defined($ct) && length($ct);
my @ct = split( /;\s*/, $ct, 2 );
for ( $ct[0] ) {
s/\s+//g;
lib/HTTP/XSHeaders.pm view on Meta::CPAN
return @res;
}
sub content_type_charset {
my $self = shift;
my $h = $self->header('content-type');
$h = $h->[0] if ref($h);
$h = "" unless defined $h;
my @v = _split_header_words($h);
if (@v) {
my($ct, undef, %ct_param) = @{$v[0]};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTPS/Handy.pm view on Meta::CPAN
'REQUEST_METHOD' => $method,
'PATH_INFO' => $path,
'QUERY_STRING' => $query_string,
'SERVER_NAME' => $server_name,
'SERVER_PORT' => $env_port,
'CONTENT_TYPE' => $headers{'content-type'} || '',
'CONTENT_LENGTH' => $content_length,
'psgi.input' => $input,
'psgi.errors' => \*STDERR,
'psgi.url_scheme' => 'https',
'psgi.ssl' => 1,
view all matches for this distribution