diff --git a/contrib/serf/CHANGES b/contrib/serf/CHANGES
index b7ee76d01209..fcab2d629247 100644
--- a/contrib/serf/CHANGES
+++ b/contrib/serf/CHANGES
@@ -1,26 +1,7 @@
-Apache Serf 1.3.9 [2016-09-01, from tags/1.3.9, rxxxx]
-  serf is now Apache Serf; apply header changes (r1700062)
-  Fix issue #151: SCons build broken when only one library in ENVPATH
-  Fix issue #153: avoid SSPI handle leak
-  Fix issue #167: Explicitly use the ANSI version of SSPI
-  Fix issue #170: Allow building with Microsoft Visual Studio 2015
-  Fix build of 'check' target when using VPATH-style builds (r1699858, ...)
-    (builddir != srcdir).
-  Resolve a bucket (aka "memory") leak when a request bucket is
-    destroyed before it is morphed into an aggregate bucket (r1699791)
-  Reset state variables when resetting connection (r1708849)
-  Fix types of passed, but unused batons (r1699986, r1699987)
-  Fix some usages of the openssl BIO api (r1699852)
-  Improve handling of bad data in the response state line. (r1699985)
-  Resolve several compiler issues with less common compilers
-  Support more overrides via SCons arguments (r1701836, ...)
-  Adapt to OpenSSL 1.1.x api (r1750819)
-
-
-Serf 1.3.8 [2014-10-20, from /tags/1.3.8, r2441]
-  Fix issue #152: CRC calculation error for gzipped http reponses > 4GB.
-  Fix issue #153: SSPI CredHandle not freed when APR pool is destroyed.
-  Fix issue #154: Disable SSLv2 and SSLv3 as both or broken.
+Serf 1.3.8 [2014-10-20, from /tags/1.3.8, rxxxx]
+Fix issue #152: CRC calculation error for gzipped http reponses > 4GB.
+Fix issue #153: SSPI CredHandle not freed when APR pool is destroyed.
+Fix issue #154: Disable SSLv2 and SSLv3 as both or broken.
 
 
 Serf 1.3.7 [2014-08-11, from /tags/1.3.7, r2411]
diff --git a/contrib/serf/NOTICE b/contrib/serf/NOTICE
index 6cc875ed93a2..3f59805ce438 100644
--- a/contrib/serf/NOTICE
+++ b/contrib/serf/NOTICE
@@ -1,7 +1,2 @@
-Apache Serf
-Copyright 2015 The Apache Software Foundation
-
-This product includes software developed by many people, and distributed
-under Contributor License Agreements to The Apache Software Foundation
-(http://www.apache.org/).  See the revision logs for an exact contribution
-history.
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/contrib/serf/README b/contrib/serf/README
index 5e972ea801d6..ead07b184e65 100644
--- a/contrib/serf/README
+++ b/contrib/serf/README
@@ -1,14 +1,15 @@
-Welcome to Apache Serf, a high-performance asynchronous HTTP client library.
+Welcome to serf, a high-performance asynchronous HTTP client library.
 
-The Apache Serf library is a C-based HTTP client library built upon the Apache
+The serf library is a C-based HTTP client library built upon the Apache
 Portable Runtime (APR) library. It multiplexes connections, running the
 read/write communication asynchronously. Memory copies and transformations are
 kept to a minimum to provide high performance operation.
 
-  * Site: http://serf.apache.org//
-  * Code: http://svn.apache.org/repos/asf/serf/
-  * Issues: https://issues.apache.org/jira/browse/SERF
-  * Mail: dev@serf.apache.org
+  * Status: http://code.google.com/p/serf/wiki/
+  * Site: http://code.google.com/p/serf/
+  * Code: http://serf.googlecode.com/svn/
+  * Issues: http://code.google.com/p/serf/issues/list
+  * Mail: serf-dev@googlegroups.com
   * People: Justin Erenkrantz, Greg Stein 
 
 ----
@@ -17,8 +18,8 @@ kept to a minimum to provide high performance operation.
 
 1.1. SCons build system
 
-Apache Serf uses SCons 2.3 for its build system. If it is not installed
-on your system, then you can install it onto your system. If you do not
+serf uses SCons 2.3 for its build system. If it is not installed on
+your system, then you can install it onto your system. If you do not
 have permissions, then you can download and install the "local"
 version into your home directory. When installed privately, simply
 create a symlink for 'scons' in your PATH to /path/to/scons/scons.py.
@@ -27,7 +28,7 @@ Fetch the scons-local package:
   http://prdownloads.sourceforge.net/scons/scons-local-2.3.0.tar.gz
 
 
-1.2 Building Apache Serf
+1.2 Building serf
 
 To build serf:
 
@@ -69,7 +70,7 @@ $ scons --help
 $ scons check
 
 
-1.4 Installing Apache Serf
+1.4 Installing serf
 
 $ scons install
 
diff --git a/contrib/serf/SConstruct b/contrib/serf/SConstruct
index 4358a2374584..0e4f98891f6b 100644
--- a/contrib/serf/SConstruct
+++ b/contrib/serf/SConstruct
@@ -1,23 +1,18 @@
 # -*- python -*-
 #
-# ====================================================================
-#    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.
-# ====================================================================
+# Copyright 2011-2012 Justin Erenkrantz and Greg Stein
+#
+# Licensed 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.
 #
 
 import sys
@@ -140,8 +135,7 @@ if sys.platform == 'win32':
     EnumVariable('MSVC_VERSION',
                  "Visual C++ to use for building (E.g. 11.0, 9.0)",
                  None,
-                 allowed_values=('14.0', '12.0',
-                                 '11.0', '10.0', '9.0', '8.0', '6.0')
+                 allowed_values=('12.0', '11.0', '10.0', '9.0', '8.0', '6.0')
                 ),
 
     # We always documented that we handle an install layout, but in fact we
@@ -183,7 +177,8 @@ CALLOUT_OKAY = not (env.GetOption('clean') or env.GetOption('help'))
 
 unknown = opts.UnknownVariables()
 if unknown:
-  print 'Warning: Used unknown variables:', ', '.join(unknown.keys())
+  print 'Unknown variables:', ', '.join(unknown.keys())
+  Exit(1)
 
 apr = str(env['APR'])
 apu = str(env['APU'])
@@ -215,8 +210,7 @@ incdir = '$PREFIX/include/serf-$MAJOR'
 # Unfortunately we can't set the .dylib compatibility_version option separately
 # from current_version, so don't use the PATCH level to avoid that build and
 # runtime patch levels have to be identical.
-if sys.platform != 'sunos5':
-  env['SHLIBVERSION'] = '%d.%d.%d' % (MAJOR, MINOR, 0)
+env['SHLIBVERSION'] = '%d.%d.%d' % (MAJOR, MINOR, 0)
 
 LIBNAME = 'libserf-%d' % (MAJOR,)
 if sys.platform != 'win32':
@@ -229,43 +223,31 @@ env.Append(RPATH=libdir,
 
 if sys.platform == 'darwin':
 #  linkflags.append('-Wl,-install_name,@executable_path/%s.dylib' % (LIBNAME,))
-  env.Append(LINKFLAGS=['-Wl,-install_name,%s/%s.dylib' % (thisdir, LIBNAME,)])
+  env.Append(LINKFLAGS='-Wl,-install_name,%s/%s.dylib' % (thisdir, LIBNAME,))
 
 if sys.platform != 'win32':
-  def CheckGnuCC(context):
-    src = '''
-    #ifndef __GNUC__
-    oh noes!
-    #endif
-    '''
-    context.Message('Checking for GNU-compatible C compiler...')
-    result = context.TryCompile(src, '.c')
-    context.Result(result)
-    return result
+  ### gcc only. figure out appropriate test / better way to check these
+  ### flags, and check for gcc.
+  env.Append(CFLAGS='-std=c89')
 
-  conf = Configure(env, custom_tests = dict(CheckGnuCC=CheckGnuCC))
-  have_gcc = conf.CheckGnuCC()
-  env = conf.Finish()
-
-  if have_gcc:
-    env.Append(CFLAGS=['-std=c89'])
+  ### These warnings are not available on Solaris
+  if sys.platform != 'sunos5': 
     env.Append(CCFLAGS=['-Wdeclaration-after-statement',
                         '-Wmissing-prototypes',
                         '-Wall'])
 
   if debug:
-    env.Append(CCFLAGS=['-g'])
+    env.Append(CCFLAGS='-g')
     env.Append(CPPDEFINES=['DEBUG', '_DEBUG'])
   else:
-    env.Append(CCFLAGS=['-O2'])
-    env.Append(CPPDEFINES=['NDEBUG'])
+    env.Append(CCFLAGS='-O2')
+    env.Append(CPPDEFINES='NDEBUG')
 
   ### works for Mac OS. probably needs to change
   env.Append(LIBS=['ssl', 'crypto', 'z', ])
 
   if sys.platform == 'sunos5':
-    env.Append(LIBS=['m'])
-    env.Append(PLATFORM='posix')
+    env.Append(LIBS='m')
 else:
   # Warning level 4, no unused argument warnings
   env.Append(CCFLAGS=['/W4', '/wd4100'])
@@ -278,8 +260,8 @@ else:
   else:
     # Optimize for speed, use DLL runtime
     env.Append(CCFLAGS=['/O2', '/MD'])
-    env.Append(CPPDEFINES=['NDEBUG'])
-    env.Append(LINKFLAGS=['/RELEASE'])
+    env.Append(CPPDEFINES='NDEBUG')
+    env.Append(LINKFLAGS='/RELEASE')
 
 # PLAN THE BUILD
 SHARED_SOURCES = []
@@ -309,7 +291,6 @@ if sys.platform == 'win32':
   if aprstatic:
     apr_libs='apr-1.lib'
     apu_libs='aprutil-1.lib'
-    env.Append(LIBS=['shell32.lib', 'xml.lib'])
   else:
     apr_libs='libapr-1.lib'
     apu_libs='libaprutil-1.lib'
@@ -326,25 +307,25 @@ if sys.platform == 'win32':
                CPPPATH=['$APR/include', '$APU/include'])
 
   # zlib
-  env.Append(LIBS=['zlib.lib'])
+  env.Append(LIBS='zlib.lib')
   if not env.get('SOURCE_LAYOUT', None):
-    env.Append(CPPPATH=['$ZLIB/include'],
-               LIBPATH=['$ZLIB/lib'])
+    env.Append(CPPPATH='$ZLIB/include',
+               LIBPATH='$ZLIB/lib')
   else:
-    env.Append(CPPPATH=['$ZLIB'],
-               LIBPATH=['$ZLIB'])
+    env.Append(CPPPATH='$ZLIB',
+               LIBPATH='$ZLIB')
 
   # openssl
   env.Append(LIBS=['libeay32.lib', 'ssleay32.lib'])
   if not env.get('SOURCE_LAYOUT', None):
-    env.Append(CPPPATH=['$OPENSSL/include/openssl'],
-               LIBPATH=['$OPENSSL/lib'])
+    env.Append(CPPPATH='$OPENSSL/include/openssl',
+               LIBPATH='$OPENSSL/lib')
   elif 0: # opensslstatic:
-    env.Append(CPPPATH=['$OPENSSL/inc32'],
-               LIBPATH=['$OPENSSL/out32'])
+    env.Append(CPPPATH='$OPENSSL/inc32',
+               LIBPATH='$OPENSSL/out32')
   else:
-    env.Append(CPPPATH=['$OPENSSL/inc32'],
-               LIBPATH=['$OPENSSL/out32dll'])
+    env.Append(CPPPATH='$OPENSSL/inc32',
+               LIBPATH='$OPENSSL/out32dll')
 else:
   if os.path.isdir(apr):
     apr = os.path.join(apr, 'bin', 'apr-1-config')
@@ -370,8 +351,8 @@ else:
     apr_libs = ''
     apu_libs = ''
 
-  env.Append(CPPPATH=['$OPENSSL/include'])
-  env.Append(LIBPATH=['$OPENSSL/lib'])
+  env.Append(CPPPATH='$OPENSSL/include')
+  env.Append(LIBPATH='$OPENSSL/lib')
 
 
 # If build with gssapi, get its information and define SERF_HAVE_GSSAPI
@@ -381,7 +362,7 @@ if gssapi and CALLOUT_OKAY:
         env['GSSAPI_LIBS'] = cmd.strip()
         return env.MergeFlags(cmd, unique)
     env.ParseConfig('$GSSAPI --libs gssapi', parse_libs)
-    env.Append(CPPDEFINES=['SERF_HAVE_GSSAPI'])
+    env.Append(CPPDEFINES='SERF_HAVE_GSSAPI')
 if sys.platform == 'win32':
   env.Append(CPPDEFINES=['SERF_HAVE_SSPI'])
 
@@ -447,12 +428,6 @@ env.Alias('install', ['install-lib', 'install-inc', 'install-pc', ])
 
 tenv = env.Clone()
 
-# MockHTTP requires C99 standard, so use it for the test suite.
-cflags = tenv['CFLAGS']
-tenv.Replace(CFLAGS = [f.replace('-std=c89', '-std=c99') for f in cflags])
-
-tenv.Append(CPPDEFINES=['MOCKHTTP_OPENSSL'])
-
 TEST_PROGRAMS = [ 'serf_get', 'serf_response', 'serf_request', 'serf_spider',
                   'test_all', 'serf_bwtp' ]
 if sys.platform == 'win32':
@@ -460,23 +435,14 @@ if sys.platform == 'win32':
 else:
   TEST_EXES = [ os.path.join('test', '%s' % (prog)) for prog in TEST_PROGRAMS ]
 
+env.AlwaysBuild(env.Alias('check', TEST_EXES, sys.executable + ' build/check.py',
+                          ENV={'PATH' : os.environ['PATH']}))
+
 # Find the (dynamic) library in this directory
 tenv.Replace(RPATH=thisdir)
 tenv.Prepend(LIBS=[LIBNAMESTATIC, ],
              LIBPATH=[thisdir, ])
 
-check_script = env.File('build/check.py').rstr()
-test_dir = env.File('test/test_all.c').rfile().get_dir()
-src_dir = env.File('serf.h').rfile().get_dir()
-test_app = ("%s %s %s %s") % (sys.executable, check_script, test_dir, 'test')
-
-# Set the library search path for the test programs
-test_env = {'PATH' : os.environ['PATH'],
-            'srcdir' : src_dir}
-if sys.platform != 'win32':
-  test_env['LD_LIBRARY_PATH'] = ':'.join(tenv.get('LIBPATH', []))
-env.AlwaysBuild(env.Alias('check', TEST_EXES, test_app, ENV=test_env))
-
 testall_files = [
         'test/test_all.c',
         'test/CuTest.c',
diff --git a/contrib/serf/auth/auth.c b/contrib/serf/auth/auth.c
index 420899947c0d..6ba3ba5ab59e 100644
--- a/contrib/serf/auth/auth.c
+++ b/contrib/serf/auth/auth.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2009 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include "serf.h"
diff --git a/contrib/serf/auth/auth.h b/contrib/serf/auth/auth.h
index b0a8c743c0a4..7d043757adee 100644
--- a/contrib/serf/auth/auth.h
+++ b/contrib/serf/auth/auth.h
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2009 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #ifndef AUTH_H
diff --git a/contrib/serf/auth/auth_basic.c b/contrib/serf/auth/auth_basic.c
index fc056d4b6002..dcee4a4ebb24 100644
--- a/contrib/serf/auth/auth_basic.c
+++ b/contrib/serf/auth/auth_basic.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2009 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 /*** Basic authentication ***/
diff --git a/contrib/serf/auth/auth_digest.c b/contrib/serf/auth/auth_digest.c
index 867d8e328cde..b2c7dec0100c 100644
--- a/contrib/serf/auth/auth_digest.c
+++ b/contrib/serf/auth/auth_digest.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2009 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 /*** Digest authentication ***/
diff --git a/contrib/serf/auth/auth_spnego.c b/contrib/serf/auth/auth_spnego.c
index e7984dab19ac..e55fad2ae938 100644
--- a/contrib/serf/auth/auth_spnego.c
+++ b/contrib/serf/auth/auth_spnego.c
@@ -1,24 +1,18 @@
-/* ====================================================================
- *    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
+/* Copyright 2009 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
-
 #include "auth_spnego.h"
 
 #ifdef SERF_HAVE_SPNEGO
diff --git a/contrib/serf/auth/auth_spnego.h b/contrib/serf/auth/auth_spnego.h
index 0ebf1f773f77..86356295c882 100644
--- a/contrib/serf/auth/auth_spnego.h
+++ b/contrib/serf/auth/auth_spnego.h
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2010 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #ifndef AUTH_SPNEGO_H
diff --git a/contrib/serf/auth/auth_spnego_gss.c b/contrib/serf/auth/auth_spnego_gss.c
index 675bdb5eb768..0f33385fe6a6 100644
--- a/contrib/serf/auth/auth_spnego_gss.c
+++ b/contrib/serf/auth/auth_spnego_gss.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2009 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include "serf.h"
diff --git a/contrib/serf/auth/auth_spnego_sspi.c b/contrib/serf/auth/auth_spnego_sspi.c
index 0882209037bd..32b719ee556a 100644
--- a/contrib/serf/auth/auth_spnego_sspi.c
+++ b/contrib/serf/auth/auth_spnego_sspi.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2010 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include "auth_spnego.h"
@@ -143,7 +138,7 @@ serf__spnego_create_sec_context(serf__spnego_context_t **ctx_p,
     else
         sspi_package = "NTLM";
 
-    sspi_status = AcquireCredentialsHandleA(
+    sspi_status = AcquireCredentialsHandle(
         NULL, sspi_package, SECPKG_CRED_OUTBOUND,
         NULL, NULL, NULL, NULL,
         &ctx->sspi_credentials, NULL);
@@ -252,7 +247,7 @@ serf__spnego_init_sec_context(serf_connection_t *conn,
     sspi_out_buffer_desc.pBuffers = &sspi_out_buffer;
     sspi_out_buffer_desc.ulVersion = SECBUFFER_VERSION;
 
-    status = InitializeSecurityContextA(
+    status = InitializeSecurityContext(
         &ctx->sspi_credentials,
         ctx->initalized ? &ctx->sspi_context : NULL,
         ctx->target_name,
diff --git a/contrib/serf/buckets/aggregate_buckets.c b/contrib/serf/buckets/aggregate_buckets.c
index 952c7d41d805..2ae3fd538b96 100644
--- a/contrib/serf/buckets/aggregate_buckets.c
+++ b/contrib/serf/buckets/aggregate_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include "serf.h"
diff --git a/contrib/serf/buckets/allocator.c b/contrib/serf/buckets/allocator.c
index bb02f45adef0..108167e016ca 100644
--- a/contrib/serf/buckets/allocator.c
+++ b/contrib/serf/buckets/allocator.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <stdlib.h>
diff --git a/contrib/serf/buckets/barrier_buckets.c b/contrib/serf/buckets/barrier_buckets.c
index 86b89840d17d..eb410eea3591 100644
--- a/contrib/serf/buckets/barrier_buckets.c
+++ b/contrib/serf/buckets/barrier_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/buckets.c b/contrib/serf/buckets/buckets.c
index c8b597ad4102..88e256b8c7fd 100644
--- a/contrib/serf/buckets/buckets.c
+++ b/contrib/serf/buckets/buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/bwtp_buckets.c b/contrib/serf/buckets/bwtp_buckets.c
index 37e774f5458f..7ef3047df2ce 100644
--- a/contrib/serf/buckets/bwtp_buckets.c
+++ b/contrib/serf/buckets/bwtp_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/chunk_buckets.c b/contrib/serf/buckets/chunk_buckets.c
index 6e590676e446..7f255088e662 100644
--- a/contrib/serf/buckets/chunk_buckets.c
+++ b/contrib/serf/buckets/chunk_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/dechunk_buckets.c b/contrib/serf/buckets/dechunk_buckets.c
index 1a2772008bdf..eda1e22642a3 100644
--- a/contrib/serf/buckets/dechunk_buckets.c
+++ b/contrib/serf/buckets/dechunk_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_strings.h>
diff --git a/contrib/serf/buckets/deflate_buckets.c b/contrib/serf/buckets/deflate_buckets.c
index 6d432562d645..348d70d993dc 100644
--- a/contrib/serf/buckets/deflate_buckets.c
+++ b/contrib/serf/buckets/deflate_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_strings.h>
diff --git a/contrib/serf/buckets/file_buckets.c b/contrib/serf/buckets/file_buckets.c
index 364cb1c98e2b..bd41cabfe507 100644
--- a/contrib/serf/buckets/file_buckets.c
+++ b/contrib/serf/buckets/file_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/headers_buckets.c b/contrib/serf/buckets/headers_buckets.c
index 35bf0536576c..04e64d19b63b 100644
--- a/contrib/serf/buckets/headers_buckets.c
+++ b/contrib/serf/buckets/headers_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <stdlib.h>
diff --git a/contrib/serf/buckets/iovec_buckets.c b/contrib/serf/buckets/iovec_buckets.c
index d31e622089c7..9ac1d8d17941 100644
--- a/contrib/serf/buckets/iovec_buckets.c
+++ b/contrib/serf/buckets/iovec_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2011 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/limit_buckets.c b/contrib/serf/buckets/limit_buckets.c
index 95c4fb1eca47..70b7efb3d620 100644
--- a/contrib/serf/buckets/limit_buckets.c
+++ b/contrib/serf/buckets/limit_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/mmap_buckets.c b/contrib/serf/buckets/mmap_buckets.c
index bfa82083943e..c96bce43fc61 100644
--- a/contrib/serf/buckets/mmap_buckets.c
+++ b/contrib/serf/buckets/mmap_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/request_buckets.c b/contrib/serf/buckets/request_buckets.c
index 8d1a963efc0d..912da8ad6df7 100644
--- a/contrib/serf/buckets/request_buckets.c
+++ b/contrib/serf/buckets/request_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
@@ -195,20 +190,6 @@ static apr_status_t serf_request_peek(serf_bucket_t *bucket,
     return serf_bucket_peek(bucket, data, len);
 }
 
-/* Note that this function is only called when serialize_data()
-   hasn't been called on the bucket */
-static void serf_request_destroy(serf_bucket_t *bucket)
-{
-  request_context_t *ctx = bucket->data;
-
-  serf_bucket_destroy(ctx->headers);
-
-  if (ctx->body)
-    serf_bucket_destroy(ctx->body);
-
-  serf_default_destroy_and_data(bucket);
-}
-
 void serf_bucket_request_become(
     serf_bucket_t *bucket,
     const char *method,
@@ -237,6 +218,6 @@ const serf_bucket_type_t serf_bucket_type_request = {
     serf_default_read_for_sendfile,
     serf_default_read_bucket,
     serf_request_peek,
-    serf_request_destroy,
+    serf_default_destroy_and_data,
 };
 
diff --git a/contrib/serf/buckets/response_body_buckets.c b/contrib/serf/buckets/response_body_buckets.c
index 3e18c07df0e5..c9648a69f6da 100644
--- a/contrib/serf/buckets/response_body_buckets.c
+++ b/contrib/serf/buckets/response_body_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/response_buckets.c b/contrib/serf/buckets/response_buckets.c
index eb72ef9906f6..39518bbd856e 100644
--- a/contrib/serf/buckets/response_buckets.c
+++ b/contrib/serf/buckets/response_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_lib.h>
@@ -133,17 +128,7 @@ static apr_status_t parse_status_line(response_context_t *ctx,
     int res;
     char *reason; /* ### stupid APR interface makes this non-const */
 
-    /* Ensure a valid length, to avoid overflow on the final '\0' */
-    if (ctx->linebuf.used >= SERF_LINEBUF_LIMIT) {
-       return SERF_ERROR_BAD_HTTP_RESPONSE;
-    }
-
-    /* apr_date_checkmask assumes its arguments are valid C strings */
-    ctx->linebuf.line[ctx->linebuf.used] = '\0';
-
-    /* ctx->linebuf.line should be of form: 'HTTP/1.1 200 OK',
-       but we also explicitly allow the forms 'HTTP/1.1 200' (no reason)
-       and 'HTTP/1.1 401.1 Logon failed' (iis extended error codes) */
+    /* ctx->linebuf.line should be of form: HTTP/1.1 200 OK */
     res = apr_date_checkmask(ctx->linebuf.line, "HTTP/#.# ###*");
     if (!res) {
         /* Not an HTTP response?  Well, at least we won't understand it. */
diff --git a/contrib/serf/buckets/simple_buckets.c b/contrib/serf/buckets/simple_buckets.c
index 656e082c41de..7ce7aeb25fd1 100644
--- a/contrib/serf/buckets/simple_buckets.c
+++ b/contrib/serf/buckets/simple_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/socket_buckets.c b/contrib/serf/buckets/socket_buckets.c
index 25dc07b54d81..d0facdab0daf 100644
--- a/contrib/serf/buckets/socket_buckets.c
+++ b/contrib/serf/buckets/socket_buckets.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/buckets/ssl_buckets.c b/contrib/serf/buckets/ssl_buckets.c
index b01e5359db08..579814ec81ac 100644
--- a/contrib/serf/buckets/ssl_buckets.c
+++ b/contrib/serf/buckets/ssl_buckets.c
@@ -1,24 +1,36 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  *
  * ----
  *
+ * For the OpenSSL thread-safety locking code:
+ *
+ * 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.
+ *
  * Originally developed by Aaron Bannert and Justin Erenkrantz, eBuilt.
  */
 
@@ -52,10 +64,6 @@
 #define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push(ary)))
 #endif
 
-#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L
-#define USE_OPENSSL_1_1_API
-#endif
-
 
 /*
  * Here's an overview of the SSL bucket's relationship to OpenSSL and serf.
@@ -144,7 +152,6 @@ struct serf_ssl_context_t {
     SSL_CTX *ctx;
     SSL *ssl;
     BIO *bio;
-    BIO_METHOD *biom;
 
     serf_ssl_stream_t encrypt;
     serf_ssl_stream_t decrypt;
@@ -237,28 +244,10 @@ apps_ssl_info_callback(const SSL *s, int where, int ret)
 }
 #endif
 
-static void bio_set_data(BIO *bio, void *data)
-{
-#ifdef USE_OPENSSL_1_1_API
-    BIO_set_data(bio, data);
-#else
-    bio->ptr = data;
-#endif
-}
-
-static void *bio_get_data(BIO *bio)
-{
-#ifdef USE_OPENSSL_1_1_API
-    return BIO_get_data(bio);
-#else
-    return bio->ptr;
-#endif
-}
-
 /* Returns the amount read. */
 static int bio_bucket_read(BIO *bio, char *in, int inlen)
 {
-    serf_ssl_context_t *ctx = bio_get_data(bio);
+    serf_ssl_context_t *ctx = bio->ptr;
     const char *data;
     apr_status_t status;
     apr_size_t len;
@@ -302,7 +291,7 @@ static int bio_bucket_read(BIO *bio, char *in, int inlen)
 /* Returns the amount written. */
 static int bio_bucket_write(BIO *bio, const char *in, int inl)
 {
-    serf_ssl_context_t *ctx = bio_get_data(bio);
+    serf_ssl_context_t *ctx = bio->ptr;
     serf_bucket_t *tmp;
 
     serf__log(SSL_VERBOSE, __FILE__, "bio_bucket_write called for %d bytes\n",
@@ -330,16 +319,19 @@ static int bio_bucket_write(BIO *bio, const char *in, int inl)
 /* Returns the amount read. */
 static int bio_file_read(BIO *bio, char *in, int inlen)
 {
-    apr_file_t *file = bio_get_data(bio);
+    apr_file_t *file = bio->ptr;
     apr_status_t status;
     apr_size_t len;
 
+    BIO_clear_retry_flags(bio);
+
     len = inlen;
     status = apr_file_read(file, in, &len);
 
     if (!SERF_BUCKET_READ_ERROR(status)) {
         /* Oh suck. */
         if (APR_STATUS_IS_EOF(status)) {
+            BIO_set_retry_read(bio);
             return -1;
         } else {
             return len;
@@ -352,7 +344,7 @@ static int bio_file_read(BIO *bio, char *in, int inlen)
 /* Returns the amount written. */
 static int bio_file_write(BIO *bio, const char *in, int inl)
 {
-    apr_file_t *file = bio_get_data(bio);
+    apr_file_t *file = bio->ptr;
     apr_size_t nbytes;
 
     BIO_clear_retry_flags(bio);
@@ -365,32 +357,15 @@ static int bio_file_write(BIO *bio, const char *in, int inl)
 
 static int bio_file_gets(BIO *bio, char *in, int inlen)
 {
-    apr_file_t *file = bio_get_data(bio);
-    apr_status_t status;
-
-    status = apr_file_gets(in, inlen, file);
-
-    if (! status) {
-        return (int)strlen(in);
-    } else if (APR_STATUS_IS_EOF(status)) {
-        return 0;
-    } else {
-        return -1; /* Signal generic error */
-    }
+    return bio_file_read(bio, in, inlen);
 }
 
 static int bio_bucket_create(BIO *bio)
 {
-#ifdef USE_OPENSSL_1_1_API
-    BIO_set_shutdown(bio, 1);
-    BIO_set_init(bio, 1);
-    BIO_set_data(bio, NULL);
-#else
     bio->shutdown = 1;
     bio->init = 1;
     bio->num = -1;
     bio->ptr = NULL;
-#endif
 
     return 1;
 }
@@ -424,7 +399,6 @@ static long bio_bucket_ctrl(BIO *bio, int cmd, long num, void *ptr)
     return ret;
 }
 
-#ifndef USE_OPENSSL_1_1_API
 static BIO_METHOD bio_bucket_method = {
     BIO_TYPE_MEM,
     "Serf SSL encryption and decryption buckets",
@@ -454,55 +428,6 @@ static BIO_METHOD bio_file_method = {
     NULL /* sslc does not have the callback_ctrl field */
 #endif
 };
-#endif
-
-static BIO_METHOD *bio_meth_bucket_new(void)
-{
-    BIO_METHOD *biom = NULL;
-
-#ifdef USE_OPENSSL_1_1_API
-    biom = BIO_meth_new(BIO_TYPE_MEM,
-                        "Serf SSL encryption and decryption buckets");
-    if (biom) {
-        BIO_meth_set_write(biom, bio_bucket_write);
-        BIO_meth_set_read(biom, bio_bucket_read);
-        BIO_meth_set_ctrl(biom, bio_bucket_ctrl);
-        BIO_meth_set_create(biom, bio_bucket_create);
-        BIO_meth_set_destroy(biom, bio_bucket_destroy);
-    }
-#else
-    biom = &bio_bucket_method;
-#endif
-
-    return biom;
-}
-
-static BIO_METHOD *bio_meth_file_new(void)
-{
-    BIO_METHOD *biom = NULL;
-
-#ifdef USE_OPENSSL_1_1_API
-    biom = BIO_meth_new(BIO_TYPE_FILE,
-                        "Wrapper around APR file structures");
-    BIO_meth_set_write(biom, bio_file_write);
-    BIO_meth_set_read(biom, bio_file_read);
-    BIO_meth_set_gets(biom, bio_file_gets);
-    BIO_meth_set_ctrl(biom, bio_bucket_ctrl);
-    BIO_meth_set_create(biom, bio_bucket_create);
-    BIO_meth_set_destroy(biom, bio_bucket_destroy);
-#else
-    biom = &bio_file_method;
-#endif
-
-    return biom;
-}
-
-static void bio_meth_free(BIO_METHOD *biom)
-{
-#ifdef USE_OPENSSL_1_1_API
-    BIO_meth_free(biom);
-#endif
-}
 
 typedef enum san_copy_t {
     EscapeNulAndCopy = 0,
@@ -1052,7 +977,7 @@ static apr_status_t ssl_encrypt(void *baton, apr_size_t bufsize,
     return status;
 }
 
-#if APR_HAS_THREADS && !defined(USE_OPENSSL_1_1_API)
+#if APR_HAS_THREADS
 static apr_pool_t *ssl_pool;
 static apr_thread_mutex_t **ssl_locks;
 
@@ -1139,7 +1064,7 @@ static void init_ssl_libraries(void)
     val = apr_atomic_cas32(&have_init_ssl, INIT_BUSY, INIT_UNINITIALIZED);
 
     if (!val) {
-#if APR_HAS_THREADS && !defined(USE_OPENSSL_1_1_API)
+#if APR_HAS_THREADS
         int i, numlocks;
 #endif
 
@@ -1156,17 +1081,13 @@ static void init_ssl_libraries(void)
         }
 #endif
 
-#ifdef USE_OPENSSL_1_1_API
-        OPENSSL_malloc_init();
-#else
         CRYPTO_malloc_init();
-#endif
         ERR_load_crypto_strings();
         SSL_load_error_strings();
         SSL_library_init();
         OpenSSL_add_all_algorithms();
 
-#if APR_HAS_THREADS && !defined(USE_OPENSSL_1_1_API)
+#if APR_HAS_THREADS
         numlocks = CRYPTO_num_locks();
         apr_pool_create(&ssl_pool, NULL);
         ssl_locks = apr_palloc(ssl_pool, sizeof(apr_thread_mutex_t*)*numlocks);
@@ -1219,7 +1140,6 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey)
         const char *cert_path;
         apr_file_t *cert_file;
         BIO *bio;
-        BIO_METHOD *biom;
         PKCS12 *p12;
         int i;
         int retrying_success = 0;
@@ -1245,9 +1165,8 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey)
             continue;
         }
 
-        biom = bio_meth_file_new();
-        bio = BIO_new(biom);
-        bio_set_data(bio, cert_file);
+        bio = BIO_new(&bio_file_method);
+        bio->ptr = cert_file;
 
         ctx->cert_path = cert_path;
         p12 = d2i_PKCS12_bio(bio, NULL);
@@ -1257,7 +1176,6 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey)
 
         if (i == 1) {
             PKCS12_free(p12);
-            bio_meth_free(biom);
             ctx->cached_cert = *cert;
             ctx->cached_cert_pw = *pkey;
             if (!retrying_success && ctx->cert_cache_pool) {
@@ -1293,7 +1211,6 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey)
                         i = PKCS12_parse(p12, password, pkey, cert, NULL);
                         if (i == 1) {
                             PKCS12_free(p12);
-                            bio_meth_free(biom);
                             ctx->cached_cert = *cert;
                             ctx->cached_cert_pw = *pkey;
                             if (!retrying_success && ctx->cert_cache_pool) {
@@ -1321,7 +1238,6 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey)
                     }
                 }
                 PKCS12_free(p12);
-                bio_meth_free(biom);
                 return 0;
             }
             else {
@@ -1329,7 +1245,6 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey)
                        ERR_GET_FUNC(err),
                        ERR_GET_REASON(err));
                 PKCS12_free(p12);
-                bio_meth_free(biom);
             }
         }
     }
@@ -1424,9 +1339,8 @@ static serf_ssl_context_t *ssl_init_context(serf_bucket_alloc_t *allocator)
     disable_compression(ssl_ctx);
 
     ssl_ctx->ssl = SSL_new(ssl_ctx->ctx);
-    ssl_ctx->biom = bio_meth_bucket_new();
-    ssl_ctx->bio = BIO_new(ssl_ctx->biom);
-    bio_set_data(ssl_ctx->bio, ssl_ctx);
+    ssl_ctx->bio = BIO_new(&bio_bucket_method);
+    ssl_ctx->bio->ptr = ssl_ctx;
 
     SSL_set_bio(ssl_ctx->ssl, ssl_ctx->bio, ssl_ctx->bio);
 
@@ -1469,7 +1383,6 @@ static apr_status_t ssl_free_context(
 
     /* SSL_free implicitly frees the underlying BIO. */
     SSL_free(ssl_ctx->ssl);
-    bio_meth_free(ssl_ctx->biom);
     SSL_CTX_free(ssl_ctx->ctx);
 
     serf_bucket_mem_free(ssl_ctx->allocator, ssl_ctx);
diff --git a/contrib/serf/build/check.py b/contrib/serf/build/check.py
index 2dacb4cd2a41..f440e45c8405 100755
--- a/contrib/serf/build/check.py
+++ b/contrib/serf/build/check.py
@@ -2,25 +2,21 @@
 #
 # check.py :  Run all the test cases.
 #
-# ===================================================================
-#   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.
-# ===================================================================
+# ====================================================================
+#   Copyright 2013 Justin Erenkrantz and Greg Stein
 #
+#   Licensed 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.
+# ====================================================================
 
 import sys
 import glob
@@ -35,11 +31,6 @@ if __name__ == '__main__':
   else:
     testdir = 'test'
 
-  if len(sys.argv) > 2:
-    test_builddir = sys.argv[2]
-  else:
-    test_builddir = 'test'
-
   # define test executable paths
   if sys.platform == 'win32':
     SERF_RESPONSE_EXE = 'serf_response.exe'
@@ -47,8 +38,8 @@ if __name__ == '__main__':
   else:
     SERF_RESPONSE_EXE = 'serf_response'
     TEST_ALL_EXE = 'test_all'
-  SERF_RESPONSE_EXE = os.path.join(test_builddir, SERF_RESPONSE_EXE)
-  TEST_ALL_EXE = os.path.join(test_builddir, TEST_ALL_EXE)
+  SERF_RESPONSE_EXE = os.path.join(testdir, SERF_RESPONSE_EXE)
+  TEST_ALL_EXE = os.path.join(testdir, TEST_ALL_EXE)
 
   # Find test responses and run them one by one
   for case in glob.glob(testdir + "/testcases/*.response"):
diff --git a/contrib/serf/build/gen_def.py b/contrib/serf/build/gen_def.py
index f4330a58e3cb..ed139e681333 100755
--- a/contrib/serf/build/gen_def.py
+++ b/contrib/serf/build/gen_def.py
@@ -2,24 +2,22 @@
 #
 # gen_def.py :  Generate the .DEF file for Windows builds
 #
-# ===================================================================
-#   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.
-# ===================================================================
+# ====================================================================
+#   Copyright 2002-2010 Justin Erenkrantz and Greg Stein
+#
+#   Licensed 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.
+# ====================================================================
+#
 #
 # Typically, this script is used like:
 #
diff --git a/contrib/serf/context.c b/contrib/serf/context.c
index 9b521381f715..b53b0a08a1c7 100644
--- a/contrib/serf/context.c
+++ b/contrib/serf/context.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
@@ -217,7 +212,7 @@ apr_status_t serf_event_trigger(
             tdesc.desc.s = conn->skt;
             tdesc.reqevents = conn->reqevents;
             ctx->pollset_rm(ctx->pollset_baton,
-                            &tdesc, &conn->baton);
+                            &tdesc, conn);
             return conn->status;
         }
         /* apr_pollset_poll() can return a conn multiple times... */
@@ -238,7 +233,7 @@ apr_status_t serf_event_trigger(
                 tdesc.desc.s = conn->skt;
                 tdesc.reqevents = conn->reqevents;
                 ctx->pollset_rm(ctx->pollset_baton,
-                                &tdesc, &conn->baton);
+                                &tdesc, conn);
             }
             return conn->status;
         }
@@ -300,9 +295,9 @@ apr_status_t serf_context_run(
     }
 
     while (num--) {
-        serf_io_baton_t *io  = desc->client_data;
+        serf_connection_t *conn = desc->client_data;
 
-        status = serf_event_trigger(ctx, io, desc);
+        status = serf_event_trigger(ctx, conn, desc);
         if (status) {
             return status;
         }
diff --git a/contrib/serf/incoming.c b/contrib/serf/incoming.c
index c978984ffd4c..2757428ece92 100644
--- a/contrib/serf/incoming.c
+++ b/contrib/serf/incoming.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
diff --git a/contrib/serf/outgoing.c b/contrib/serf/outgoing.c
index 5f5f6b51da45..3fc726c038e4 100644
--- a/contrib/serf/outgoing.c
+++ b/contrib/serf/outgoing.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #include <apr_pools.h>
@@ -147,7 +142,7 @@ apr_status_t serf__conn_update_pollset(serf_connection_t *conn)
     desc.reqevents = conn->reqevents;
 
     status = ctx->pollset_rm(ctx->pollset_baton,
-                             &desc, &conn->baton);
+                             &desc, conn);
     if (status && !APR_STATUS_IS_NOTFOUND(status))
         return status;
 
@@ -552,7 +547,7 @@ static apr_status_t remove_connection(serf_context_t *ctx,
     desc.reqevents = conn->reqevents;
 
     return ctx->pollset_rm(ctx->pollset_baton,
-                           &desc, &conn->baton);
+                           &desc, conn);
 }
 
 /* A socket was closed, inform the application. */
@@ -628,11 +623,6 @@ static apr_status_t reset_connection(serf_connection_t *conn,
     conn->ctx->dirty_pollset = 1;
     conn->state = SERF_CONN_INIT;
 
-    conn->hit_eof = 0;
-    conn->connect_time = 0;
-    conn->latency = -1;
-    conn->stop_writing = 0;
-
     serf__log(CONN_VERBOSE, __FILE__, "reset connection 0x%x\n", conn);
 
     conn->status = APR_SUCCESS;
diff --git a/contrib/serf/serf.h b/contrib/serf/serf.h
index f9fb97523511..79504a5617e6 100644
--- a/contrib/serf/serf.h
+++ b/contrib/serf/serf.h
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #ifndef SERF_H
@@ -1067,7 +1062,7 @@ void serf_debug__bucket_alloc_check(
 /* Version info */
 #define SERF_MAJOR_VERSION 1
 #define SERF_MINOR_VERSION 3
-#define SERF_PATCH_VERSION 9
+#define SERF_PATCH_VERSION 8
 
 /* Version number string */
 #define SERF_VERSION_STRING APR_STRINGIFY(SERF_MAJOR_VERSION) "." \
diff --git a/contrib/serf/serf_bucket_types.h b/contrib/serf/serf_bucket_types.h
index 190dd12b974f..900f67d1673f 100644
--- a/contrib/serf/serf_bucket_types.h
+++ b/contrib/serf/serf_bucket_types.h
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #ifndef SERF_BUCKET_TYPES_H
diff --git a/contrib/serf/serf_bucket_util.h b/contrib/serf/serf_bucket_util.h
index dbacd3d8978d..b146c226839d 100644
--- a/contrib/serf/serf_bucket_util.h
+++ b/contrib/serf/serf_bucket_util.h
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #ifndef SERF_BUCKET_UTIL_H
diff --git a/contrib/serf/serf_private.h b/contrib/serf/serf_private.h
index f906379b6798..d38680b473bc 100644
--- a/contrib/serf/serf_private.h
+++ b/contrib/serf/serf_private.h
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 #ifndef _SERF_PRIVATE_H_
diff --git a/contrib/serf/ssltunnel.c b/contrib/serf/ssltunnel.c
index 2c5c885a9c61..0ad04d677036 100644
--- a/contrib/serf/ssltunnel.c
+++ b/contrib/serf/ssltunnel.c
@@ -1,21 +1,16 @@
-/* ====================================================================
- *    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
+/* Copyright 2011 Justin Erenkrantz and Greg Stein
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed 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
  *
- *    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.
- * ====================================================================
+ *     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.
  */
 
 /*** Setup a SSL tunnel over a HTTP proxy, according to RFC 2817. ***/
diff --git a/contrib/telnet/libtelnet/enc_des.c b/contrib/telnet/libtelnet/enc_des.c
index 72ad44c7fde0..2f7fe6e74402 100644
--- a/contrib/telnet/libtelnet/enc_des.c
+++ b/contrib/telnet/libtelnet/enc_des.c
@@ -207,9 +207,9 @@ fb64_start(struct fb *fbp, int dir, int server __unused)
 		/*
 		 * Create a random feed and send it over.
 		 */
-		DES_random_key((Block *)fbp->temp_feed);
-		DES_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed,
-				&fbp->krbdes_sched, 1);
+		des_random_key((Block *)fbp->temp_feed);
+		des_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed,
+				fbp->krbdes_sched, 1);
 		p = fbp->fb_feed + 3;
 		*p++ = ENCRYPT_IS;
 		p++;
@@ -393,7 +393,7 @@ fb64_session(Session_Key *key, int server, struct fb *fbp)
 	fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT-1]);
 	fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]);
 
-	DES_key_sched((Block *)fbp->krbdes_key, &fbp->krbdes_sched);
+	des_key_sched((Block *)fbp->krbdes_key, fbp->krbdes_sched);
 	/*
 	 * Now look to see if krbdes_start() was was waiting for
 	 * the key to show up.  If so, go ahead an call it now
@@ -499,7 +499,7 @@ fb64_stream_iv(Block seed, struct stinfo *stp)
 	memmove((void *)stp->str_iv, (void *)seed, sizeof(Block));
 	memmove((void *)stp->str_output, (void *)seed, sizeof(Block));
 
-	DES_key_sched((Block *)stp->str_ikey, &stp->str_sched);
+	des_key_sched((Block *)stp->str_ikey, stp->str_sched);
 
 	stp->str_index = sizeof(Block);
 }
@@ -508,7 +508,7 @@ void
 fb64_stream_key(Block key, struct stinfo *stp)
 {
 	memmove((void *)stp->str_ikey, (void *)key, sizeof(Block));
-	DES_key_sched((Block *)key, &stp->str_sched);
+	des_key_sched((Block *)key, stp->str_sched);
 
 	memmove((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block));
 
@@ -547,7 +547,7 @@ cfb64_encrypt(unsigned char *s, int c)
 	while (c-- > 0) {
 		if (idx == sizeof(Block)) {
 			Block b;
-			DES_ecb_encrypt((Block *)stp->str_output, (Block *)b, &stp->str_sched, 1);
+			des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1);
 			memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
 			idx = 0;
 		}
@@ -580,7 +580,7 @@ cfb64_decrypt(int data)
 	idx = stp->str_index++;
 	if (idx == sizeof(Block)) {
 		Block b;
-		DES_ecb_encrypt((Block *)stp->str_output, (Block *)b, &stp->str_sched, 1);
+		des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1);
 		memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
 		stp->str_index = 1;	/* Next time will be 1 */
 		idx = 0;		/* But now use 0 */
@@ -620,7 +620,7 @@ ofb64_encrypt(unsigned char *s, int c)
 	while (c-- > 0) {
 		if (idx == sizeof(Block)) {
 			Block b;
-			DES_ecb_encrypt((Block *)stp->str_feed, (Block *)b, &stp->str_sched, 1);
+			des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1);
 			memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
 			idx = 0;
 		}
@@ -650,7 +650,7 @@ ofb64_decrypt(int data)
 	idx = stp->str_index++;
 	if (idx == sizeof(Block)) {
 		Block b;
-		DES_ecb_encrypt((Block *)stp->str_feed, (Block *)b, &stp->str_sched, 1);
+		des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1);
 		memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
 		stp->str_index = 1;	/* Next time will be 1 */
 		idx = 0;		/* But now use 0 */
diff --git a/contrib/telnet/libtelnet/encrypt.h b/contrib/telnet/libtelnet/encrypt.h
index 5574a3cd4ccf..eda8d57e0328 100644
--- a/contrib/telnet/libtelnet/encrypt.h
+++ b/contrib/telnet/libtelnet/encrypt.h
@@ -67,7 +67,7 @@ typedef unsigned char *BlockT;
 #if 0
 typedef struct { Block __; } Schedule[16];
 #else
-#define Schedule DES_key_schedule
+#define Schedule des_key_schedule
 #endif
 
 #define	VALIDKEY(key)	( key[0] | key[1] | key[2] | key[3] | \
diff --git a/contrib/telnet/libtelnet/kerberos.c b/contrib/telnet/libtelnet/kerberos.c
index 990e4a972880..2380c27daa5e 100644
--- a/contrib/telnet/libtelnet/kerberos.c
+++ b/contrib/telnet/libtelnet/kerberos.c
@@ -91,7 +91,7 @@ static	char name[ANAME_SZ];
 static	AUTH_DAT adat = { 0, "", "", "", 0, {}, 0, 0, 0, { 0, "", 0 } };
 #ifdef	ENCRYPTION
 static Block	session_key	= { 0 };
-static DES_key_schedule sched;
+static des_key_schedule sched;
 static Block	challenge	= { 0 };
 #endif	/* ENCRYPTION */
 
@@ -206,10 +206,10 @@ kerberos4_send(Authenticator *ap)
 	if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
 		register int i;
 
-		DES_key_sched(&cred.session, sched);
-		DES_random_key(&session_key);
-		DES_ecb_encrypt(&session_key, &session_key, sched, 0);
-		DES_ecb_encrypt(&session_key, &challenge, sched, 0);
+		des_key_sched(&cred.session, sched);
+		des_random_key(&session_key);
+		des_ecb_encrypt(&session_key, &session_key, sched, 0);
+		des_ecb_encrypt(&session_key, &challenge, sched, 0);
 		/*
 		 * Increment the challenge by 1, and encrypt it for
 		 * later comparison.
@@ -221,7 +221,7 @@ kerberos4_send(Authenticator *ap)
 			if (x < 256)		/* if no overflow, all done */
 				break;
 		}
-		DES_ecb_encrypt(&challenge, &challenge, sched, 1);
+		des_ecb_encrypt(&challenge, &challenge, sched, 1);
 	}
 #endif	/* ENCRYPTION */
 
@@ -298,14 +298,14 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt)
 			break;
 		}
 
-		DES_key_sched(&session_key, sched);
+		des_key_sched(&session_key, sched);
 		memmove((void *)datablock, (void *)data, sizeof(Block));
 		/*
 		 * Take the received encrypted challenge, and encrypt
 		 * it again to get a unique session_key for the
 		 * ENCRYPT option.
 		 */
-		DES_ecb_encrypt(&datablock, &session_key, sched, 1);
+		des_ecb_encrypt(&datablock, &session_key, sched, 1);
 		skey.type = SK_DES;
 		skey.length = 8;
 		skey.data = session_key;
@@ -314,7 +314,7 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt)
 		 * Now decrypt the received encrypted challenge,
 		 * increment by one, re-encrypt it and send it back.
 		 */
-		DES_ecb_encrypt(&datablock, &challenge, sched, 0);
+		des_ecb_encrypt(&datablock, &challenge, sched, 0);
 		for (r = 7; r >= 0; r--) {
 			register int t;
 			t = (unsigned int)challenge[r] + 1;
@@ -322,7 +322,7 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt)
 			if (t < 256)		/* if no overflow, all done */
 				break;
 		}
-		DES_ecb_encrypt(&challenge, &challenge, sched, 1);
+		des_ecb_encrypt(&challenge, &challenge, sched, 1);
 		Data(ap, KRB_RESPONSE, challenge, sizeof(challenge));
 #endif	/* ENCRYPTION */
 		break;
@@ -364,7 +364,7 @@ kerberos4_reply(Authenticator *ap, unsigned char *data, int cnt)
 #else	/* ENCRYPTION */
 			Data(ap, KRB_CHALLENGE, session_key,
 						sizeof(session_key));
-			DES_ecb_encrypt(&session_key, &session_key, sched, 1);
+			des_ecb_encrypt(&session_key, &session_key, sched, 1);
 			skey.type = SK_DES;
 			skey.length = 8;
 			skey.data = session_key;
diff --git a/contrib/telnet/libtelnet/pk.c b/contrib/telnet/libtelnet/pk.c
index 29be15e5f8eb..52efebad4693 100644
--- a/contrib/telnet/libtelnet/pk.c
+++ b/contrib/telnet/libtelnet/pk.c
@@ -129,7 +129,7 @@ common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey)
         mp_pow(public, secret, modulus, common);
         extractdeskey(common, deskey);
         extractideakey(common, ideakey);
-	DES_set_odd_parity(deskey);
+	des_set_odd_parity(deskey);
         mp_mfree(common);
         mp_mfree(secret);
         mp_mfree(public);
@@ -221,14 +221,14 @@ pk_encode(char *in, char *out, DesData *key)
 {
 	char buf[256];
 	DesData i;
-	DES_key_schedule k;
+	des_key_schedule k;
 	int l,op,deslen;
 
 	memset(&i,0,sizeof(i));
 	memset(buf,0,sizeof(buf));
 	deslen = ((strlen(in) + 7)/8)*8;
-	DES_key_sched(key, &k);
-	DES_cbc_encrypt(in, buf, deslen, &k, &i, DES_ENCRYPT);
+	des_key_sched(key, k);
+	des_cbc_encrypt(in,buf,deslen, k,&i,DES_ENCRYPT);
 	for (l=0,op=0;l<deslen;l++) {
 		out[op++] = hextab[(buf[l] & 0xf0) >> 4];
 		out[op++] = hextab[(buf[l] & 0x0f)];
@@ -242,7 +242,7 @@ pk_decode(char *in, char *out, DesData *key)
 {
 	char buf[256];
 	DesData i;
-	DES_key_schedule k;
+	des_key_schedule k;
 	int n1,n2,op;
 	size_t l;
 
@@ -259,7 +259,7 @@ pk_decode(char *in, char *out, DesData *key)
 			n2 = in[op+1] - '0';
 		buf[l] = n1*16 +n2;
 	}
-	DES_key_sched(key, &k);
-	DES_cbc_encrypt(buf, out, strlen(in) / 2, &k, &i, DES_DECRYPT);
+	des_key_sched(key, k);
+	des_cbc_encrypt(buf,out,strlen(in)/2, k,&i,DES_DECRYPT);
 	out[strlen(in)/2] = '\0';
 }
diff --git a/contrib/telnet/libtelnet/pk.h b/contrib/telnet/libtelnet/pk.h
index 0c254a80c162..555d8ebdeb78 100644
--- a/contrib/telnet/libtelnet/pk.h
+++ b/contrib/telnet/libtelnet/pk.h
@@ -32,7 +32,7 @@
 /* header for the des routines that we will use */
 
 typedef unsigned char byte, DesData[ 8], IdeaData[16];
-#define DesKeys DES_key_schedule
+#define DesKeys des_key_schedule
 
 #define DES_DECRYPT 0
 #define DES_ENCRYPT 1
diff --git a/contrib/unbound/config.h b/contrib/unbound/config.h
index fce5a1594007..868066e2da95 100644
--- a/contrib/unbound/config.h
+++ b/contrib/unbound/config.h
@@ -135,7 +135,7 @@
 #define HAVE_DLFCN_H 1
 
 /* Define to 1 if you have the `DSA_SIG_set0' function. */
-#define HAVE_DSA_SIG_SET0 1
+/* #undef HAVE_DSA_SIG_SET0 */
 
 /* Define to 1 if you have the <endian.h> header file. */
 /* #undef HAVE_ENDIAN_H */
@@ -177,10 +177,10 @@
 /* #undef HAVE_EVP_DIGESTVERIFY */
 
 /* Define to 1 if you have the `EVP_dss1' function. */
-/* #undef HAVE_EVP_DSS1 */
+#define HAVE_EVP_DSS1 1
 
 /* Define to 1 if you have the `EVP_MD_CTX_new' function. */
-#define HAVE_EVP_MD_CTX_NEW 1
+/* #undef HAVE_EVP_MD_CTX_NEW */
 
 /* Define to 1 if you have the `EVP_sha1' function. */
 #define HAVE_EVP_SHA1 1