From bb9bc9051629c3319c56785c2f4ae0e605d76329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 21 Nov 2015 14:51:17 +0100 Subject: Initial import of bitz-server version 0.1.6-1 --- test/icap-client.py | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++++ test/sample.txt | 192 +++++++++++++++++++++++++++++++++++++++++++++++ test/valgrind.supp | 29 ++++++++ 3 files changed, 432 insertions(+) create mode 100644 test/icap-client.py create mode 100644 test/sample.txt create mode 100644 test/valgrind.supp (limited to 'test') diff --git a/test/icap-client.py b/test/icap-client.py new file mode 100644 index 0000000..622d9ca --- /dev/null +++ b/test/icap-client.py @@ -0,0 +1,211 @@ +#!/usr/bin/env python +# +# icap-client.py +# Copyright (c) 2013 Uditha Atukorala +# + +# simple icap client to test a server implementation + +import socket +import sys + +HOST = 'localhost' +SERVICE = 'icap://icap.server.net/sample-service' +PORT = 1344 + +# OPTIONS +print "----- OPTIONS -----" +try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(1) + +try: + sock.connect((HOST, PORT)) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(2) + +sock.send( "OPTIONS %s ICAP/1.0\r\n" % ( SERVICE ) ) +sock.send( "Host: %s\r\n" % ( HOST ) ) +sock.send( "User-Agent: Python ICAP tester\r\n" ) +sock.send( "\r\n" ) + + +data = sock.recv(1024) +string = "" +while len(data): + string = string + data + data = sock.recv(1024) +sock.close() + +print string + + +# REQMOD, GET +print "----- REQMOD - GET -----" +try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(1) + +try: + sock.connect((HOST, PORT)) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(2) + +sock.send( "REQMOD %s ICAP/1.0\r\n" % ( SERVICE ) ) +sock.send( "Host: %s\r\n" % ( HOST ) ) +sock.send( "Encapsulated: req-hdr=0, null-body=170\r\n" ) +sock.send( "\r\n" ) + +sock.send( "GET / HTTP/1.1\r\n" ) +sock.send( "Host: www.origin-server.com\r\n" ) +sock.send( "Accept: text/html, text/plain\r\n" ) +sock.send( "Accept-Encoding: compress\r\n" ) +sock.send( "Cookie: ff39fk3jur@4ii0e02i\r\n" ) +sock.send( "If-None-Match: \"xyzzy\", \"r2d2xxxe\"\r\n" ) +sock.send( "\r\n" ) + + +data = sock.recv(1024) +string = "" +while len(data): + string = string + data + data = sock.recv(1024) +sock.close() + +print string + + +# REQMOD, POST +print "----- REQMOD - POST -----" +try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(1) + +try: + sock.connect((HOST, PORT)) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(2) + +sock.send( "REQMOD %s ICAP/1.0\r\n" % ( SERVICE ) ) +sock.send( "Host: %s\r\n" % ( HOST ) ) +sock.send( "Encapsulated: req-hdr=0, req-body=147\r\n" ) +sock.send( "\r\n" ) + +sock.send( "POST /origin-resource/form.pl HTTP/1.1\r\n" ) +sock.send( "Host: www.origin-server.com\r\n" ) +sock.send( "Accept: text/html, text/plain\r\n" ) +sock.send( "Accept-Encoding: compress\r\n" ) +sock.send( "Pragma: no-cache\r\n" ) +sock.send( "\r\n" ) +sock.send( "1e\r\n" ) +sock.send( "I am posting this information.\r\n" ) +sock.send( "0\r\n" ) +sock.send( "\r\n" ) + +data = sock.recv(1024) +string = "" +while len(data): + string = string + data + data = sock.recv(1024) +sock.close() + +print string + + +# REQMOD - Message preview +print "----- REQMOD - Message preview -----" +try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(1) + +try: + sock.connect((HOST, PORT)) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(2) + +sock.send( "REQMOD %s ICAP/1.0\r\n" % ( SERVICE ) ) +sock.send( "Host: %s\r\n" % ( HOST ) ) +sock.send( "Preview: 1024\r\n" ) +sock.send( "Encapsulated: req-hdr=0, req-body=147\r\n" ) +sock.send( "\r\n" ) + +sock.send( "POST /origin-resource/form.pl HTTP/1.1\r\n" ) +sock.send( "Host: www.origin-server.com\r\n" ) +sock.send( "Accept: text/html, text/plain\r\n" ) +sock.send( "Accept-Encoding: compress\r\n" ) +sock.send( "Pragma: no-cache\r\n" ) +sock.send( "\r\n" ) +sock.send( "1e\r\n" ) +sock.send( "I am posting this information.\r\n" ) +sock.send( "0; ieof\r\n\r\n" ) + +data = sock.recv(1024) +string = "" +while len(data): + string = string + data + data = sock.recv(1024) +sock.close() + +print string + + +# RESPMOD +print "----- RESPMOD -----" +try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(1) + +try: + sock.connect((HOST, PORT)) +except socket.error, msg: + sys.stderr.write("[ERROR] %s\n" % msg[1]) + sys.exit(2) + +sock.send( "RESPMOD %s ICAP/1.0\r\n" % ( SERVICE ) ) +sock.send( "Host: %s\r\n" % ( HOST ) ) +sock.send( "Encapsulated: req-hdr=0, res-hdr=137, res-body=296\r\n" ) +sock.send( "\r\n" ) + +sock.send( "GET /origin-resource HTTP/1.1\r\n" ) +sock.send( "Host: www.origin-server.com\r\n" ) +sock.send( "Accept: text/html, text/plain, image/gif\r\n" ) +sock.send( "Accept-Encoding: gzip, compress\r\n" ) +sock.send( "\r\n" ) +sock.send( "HTTP/1.1 200 OK\r\n" ) +sock.send( "Date: Mon, 10 Jan 2000 09:52:22 GMT\r\n" ) +sock.send( "Server: Apache/1.3.6 (Unix)\r\n" ) +sock.send( 'ETag: "63840-1ab7-378d415b"\r\n' ) +sock.send( "Content-Type: text/html\r\n" ) +sock.send( "Content-Length: 51\r\n" ) +sock.send( "\r\n" ) +sock.send( "33\r\n" ) +sock.send( "This is data that was returned by an origin server.\r\n" ) +sock.send( "0\r\n" ) +sock.send( "\r\n" ) + +data = sock.recv(1024) +string = "" +while len(data): + string = string + data + data = sock.recv(1024) +sock.close() + +print string + + +sys.exit(0) + diff --git a/test/sample.txt b/test/sample.txt new file mode 100644 index 0000000..a149049 --- /dev/null +++ b/test/sample.txt @@ -0,0 +1,192 @@ +REQMOD +====== + +ICAP Request Modification Example 1 - ICAP Request +---------------------------------------------------------------- +REQMOD icap://icap-server.net/server?arg=87 ICAP/1.0 +Host: icap-server.net +Encapsulated: req-hdr=0, null-body=170 + +GET / HTTP/1.1 +Host: www.origin-server.com +Accept: text/html, text/plain +Accept-Encoding: compress +Cookie: ff39fk3jur@4ii0e02i +If-None-Match: "xyzzy", "r2d2xxxx" + +---------------------------------------------------------------- +ICAP Request Modification Example 1 - ICAP Response +---------------------------------------------------------------- +ICAP/1.0 200 OK +Date: Mon, 10 Jan 2000 09:55:21 GMT +Server: ICAP-Server-Software/1.0 +Connection: close +ISTag: "W3E4R7U9-L2E4-2" +Encapsulated: req-hdr=0, null-body=231 + +GET /modified-path HTTP/1.1 +Host: www.origin-server.com +Via: 1.0 icap-server.net (ICAP Example ReqMod Service 1.1) +Accept: text/html, text/plain, image/gif +Accept-Encoding: gzip, compress +If-None-Match: "xyzzy", "r2d2xxxx" + +---------------------------------------------------------------- + + + +ICAP Request Modification Example 2 - ICAP Request +---------------------------------------------------------------- +REQMOD icap://icap-server.net/server?arg=87 ICAP/1.0 +Host: icap-server.net +Encapsulated: req-hdr=0, req-body=147 + +POST /origin-resource/form.pl HTTP/1.1 +Host: www.origin-server.com +Accept: text/html, text/plain +Accept-Encoding: compress +Pragma: no-cache + +1e +I am posting this information. +0 + +---------------------------------------------------------------- +ICAP Request Modification Example 2 - ICAP Response +---------------------------------------------------------------- +ICAP/1.0 200 OK +Date: Mon, 10 Jan 2000 09:55:21 GMT +Server: ICAP-Server-Software/1.0 +Connection: close +ISTag: "W3E4R7U9-L2E4-2" +Encapsulated: req-hdr=0, req-body=244 + +POST /origin-resource/form.pl HTTP/1.1 +Host: www.origin-server.com +Via: 1.0 icap-server.net (ICAP Example ReqMod Service 1.1) +Accept: text/html, text/plain, image/gif +Accept-Encoding: gzip, compress +Pragma: no-cache +Content-Length: 45 + +2d +I am posting this information. ICAP powered! +0 + +---------------------------------------------------------------- + + +ICAP Request Modification Example 3 - ICAP Request +---------------------------------------------------------------- +REQMOD icap://icap-server.net/content-filter ICAP/1.0 +Host: icap-server.net +Encapsulated: req-hdr=0, null-body=119 + +GET /naughty-content HTTP/1.1 +Host: www.naughty-site.com +Accept: text/html, text/plain +Accept-Encoding: compress + +---------------------------------------------------------------- +ICAP Request Modification Example 3 - ICAP Response +---------------------------------------------------------------- +ICAP/1.0 200 OK +Date: Mon, 10 Jan 2000 09:55:21 GMT +Server: ICAP-Server-Software/1.0 +Connection: close +ISTag: "W3E4R7U9-L2E4-2" +Encapsulated: res-hdr=0, res-body=213 + +HTTP/1.1 403 Forbidden +Date: Wed, 08 Nov 2000 16:02:10 GMT +Server: Apache/1.3.12 (Unix) +Last-Modified: Thu, 02 Nov 2000 13:51:37 GMT +ETag: "63600-1989-3a017169" +Content-Length: 58 +Content-Type: text/html + +3a +Sorry, you are not allowed to access that naughty content. +0 + +---------------------------------------------------------------- + + +RESPMOD +======= + +ICAP Response Modification Example 4 - ICAP Request +---------------------------------------------------------------- +RESPMOD icap://icap.example.org/satisf ICAP/1.0 +Host: icap.example.org +Encapsulated: req-hdr=0, res-hdr=137, res-body=296 + +GET /origin-resource HTTP/1.1 +Host: www.origin-server.com +Accept: text/html, text/plain, image/gif +Accept-Encoding: gzip, compress + +HTTP/1.1 200 OK +Date: Mon, 10 Jan 2000 09:52:22 GMT +Server: Apache/1.3.6 (Unix) +ETag: "63840-1ab7-378d415b" +Content-Type: text/html +Content-Length: 51 + +33 +This is data that was returned by an origin server. +0 + +---------------------------------------------------------------- +ICAP Response Modification Example 4 - ICAP Response +---------------------------------------------------------------- +ICAP/1.0 200 OK +Date: Mon, 10 Jan 2000 09:55:21 GMT +Server: ICAP-Server-Software/1.0 +Connection: close +ISTag: "W3E4R7U9-L2E4-2" +Encapsulated: res-hdr=0, res-body=222 + +HTTP/1.1 200 OK +Date: Mon, 10 Jan 2000 09:55:21 GMT +Via: 1.0 icap.example.org (ICAP Example RespMod Service 1.1) +Server: Apache/1.3.6 (Unix) +ETag: "63840-1ab7-378d415b" +Content-Type: text/html +Content-Length: 92 + +5c +This is data that was returned by an origin server, but with +value added by an ICAP server. +0 + +---------------------------------------------------------------- + + +OPTIONS +======= + +ICAP OPTIONS Example 5 - ICAP OPTIONS Request +---------------------------------------------------------------- +OPTIONS icap://icap.server.net/sample-service ICAP/1.0 +Host: icap.server.net +User-Agent: BazookaDotCom-ICAP-Client-Library/2.3 + +---------------------------------------------------------------- +ICAP OPTIONS Example 5 - ICAP OPTIONS Response +---------------------------------------------------------------- +ICAP/1.0 200 OK +Date: Mon, 10 Jan 2000 09:55:21 GMT +Methods: RESPMOD +Service: FOO Tech Server 1.0 +ISTag: "W3E4R7U9-L2E4-2" +Encapsulated: null-body=0 +Max-Connections: 1000 +Options-TTL: 7200 +Allow: 204 +Preview: 2048 +Transfer-Complete: asp, bat, exe, com +Transfer-Ignore: html +Transfer-Preview: * + +---------------------------------------------------------------- \ No newline at end of file diff --git a/test/valgrind.supp b/test/valgrind.supp new file mode 100644 index 0000000..be525db --- /dev/null +++ b/test/valgrind.supp @@ -0,0 +1,29 @@ +# +# valgrind.supp +# + +# Python +{ + Python 2.7 (libpython2.7.so.1.0) + Memcheck:Value4 + obj:/usr/lib/libpython2.7.so.1.0 +} + +{ + Python 2.7 (libpython2.7.so.1.0) + Memcheck:Addr4 + obj:/usr/lib/libpython2.7.so.1.0 +} + +{ + Python 2.7 (libpython2.7.so.1.0) + Memcheck:Value8 + obj:/usr/lib/libpython2.7.so.1.0 +} + +{ + Python 2.7 (libpython2.7.so.1.0) + Memcheck:Cond + obj:/usr/lib/libpython2.7.so.1.0 +} + -- cgit v1.2.3