File: normalise_result

package info (click to toggle)
davical 1.1.12-2.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,020 kB
  • sloc: php: 19,361; sql: 4,514; perl: 3,524; sh: 554; javascript: 162; makefile: 85
file content (66 lines) | stat: -rwxr-xr-x 1,388 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl -w
#
# Given a result on stdin, try and normalise some
# elements of it (such as HTTP Header dates) so that we can
# simply compare it with other results
#

use strict;
my $no_content = 0;

while( <STDIN> ) {

  /^Server: Apache(\/[0-9.]+)?/ && do {
    $_ = "";
  };

  /^X-Powered-By: PHP\/[0-9.]+/ && do {
    $_ = "";
  };

  /^X-Pad: avoid browser bug/ && do {
    $_ = "";
  };

  /^Keep-Alive:/ && do {
    $_ = "";
  };

  /^Connection:/ && do {
    $_ = "";
  };

  /^Transfer-Encoding:/ && do {
    $_ = "";
  };

  /^Vary: / && do {
    $_ = "";
  };

  /^X-(DAViCal|RSCDS)-Version: (DAViCal|RSCDS)\/[0-9.]+\.[0-9.]+\.[0-9.]+; DB\/[0-9.]+\.[0-9.]+\.[0-9.]+/ && do {
    $_ = "";
  };

  # HTTP Standard Dates
  s/(Mon|Tue|Wed|Thu|Fri|Sat|Sun), [0-3][0-9] (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) 2[0-9]{3} [0-2][0-9](:[0-5][0-9]){2} GMT/Dow, 01 Jan 2000 00:00:00 GMT/;

  # Fix up any opaquelocktokens to something regular
  s/opaquelocktoken:[[:xdigit:]]{8}-([[:xdigit:]]{4}-){3}[[:xdigit:]]{12}/opaquelocktoken:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/;

  /^HTTP\/1\.1 204 No Content/ && do {
    $no_content = 1;
  };
  /^Content-Length: 0/ && $no_content && do {
    $_ = "";
  };
  /^Content-Type: / && $no_content && do {
    $_ = "";
  };
  /^HTTP\/1\.1 100 Continue/ && do {
    my $swallow_next_line_as_well = <STDIN>;
    next;
  };

  print;
}