blob: 73c5a0ad9c8d1bbef79a5bb11e9fe57d52aca0b0 [file]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# A very simple cleartext server for one HTTP transaction. Does no validation of the Request message.
response ()
{
# Wait for end of Request message.
#
while (( 1 == 1 ))
do
if [[ -f $outfile ]] ; then
if tr '\r' '=' < $outfile | grep '^=$' > /dev/null
then
break;
fi
fi
sleep 1
done
# respond even if the method is funky
printf "HTTP/1.1 200 OK\r\n"
printf "Content-Length: 0\r\n"
printf "X-Resp-Id: 3\r\n"
printf "\r\n"
}
outfile=$2
response | nc -l $1 > $outfile