Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / resources / post-and-verify-hybrid.cgi
blob9b2bf9818f4aa3239a2fefe765be44dd9f3c1745
1 #!/usr/bin/perl -wT
3 use Config;
5 print "Content-type: text/plain\n\n";
7 if ($ENV{'REQUEST_METHOD'} eq "POST") {
8 if ($ENV{'CONTENT_LENGTH'}) {
9 read(STDIN, $postData, $ENV{'CONTENT_LENGTH'}) || die "Could not get post data\n";
10 } else {
11 $postData = "";
14 @list = split(/&/, $ENV{'QUERY_STRING'});
15 @values;
16 $values{'start'} = 0;
17 $values{'length'} = -1;
18 $values{'convert_newlines'} = 0;
19 foreach $element (@list) {
20 ($key, $value) = split(/=/, $element);
21 $values{$key} = $value;
24 # 'items' parameter would look like:
25 # <items> := <item>(','<item>)*
26 # <item> := <file> | <data>
27 # <file> := "file":<file-path>
28 # <data> := "data":<data-string>
29 @items = split(/,/, $values{'items'});
30 $expectedData = "";
31 $readPos = $values{'start'};
32 $remainingLength = $values{'length'};
33 foreach $item (@items) {
34 my ($type, $data) = split(/:/, $item);
35 my $size;
36 if ($type eq "data") {
37 $data =~ s/%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
38 $size = length($data);
39 if ($readPos > 0) {
40 if ($readPos > $size) {
41 $readPos -= $size;
42 next;
44 $data = substr($data, $readPos);
46 $data = substr($data, 0, $remainingLength) if ($remainingLength > 0);
47 } else {
48 $path = $data;
49 open(FILE, $path) || next;
50 $size = -s $path;
51 if ($readPos > 0) {
52 if ($readPos > $size) {
53 $readPos -= $size;
54 next;
56 seek(FILE, $readPos, 0);
58 if ($remainingLength > 0) {
59 read(FILE, $data, $remainingLength);
60 } else {
61 local $/ = undef;
62 $data = <FILE>;
64 close(FILE);
66 $readPos -= $size;
67 $expectedData .= $data;
68 if ($remainingLength > 0) {
69 $remainingLength -= length($data);
70 last if $remainingLength <= 0;
74 if ($values{'convert_newlines'}) {
75 $nativeEnding = ($Config{osname} =~ /(MSWin|cygwin)/) ? "\r\n" : "\n";
76 $postData =~ s/$nativeEnding/[NL]/g;
79 if ($postData eq $expectedData) {
80 print "OK";
81 } else {
82 print "FAILED";
84 } else {
85 print "Wrong method: " . $ENV{'REQUEST_METHOD'} . "\n";