X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;ds=sidebyside;f=src%2Futil.cpp;h=c8cf573b81248f97cb8d22aadc49962a4a46e1e7;hb=1751782d8e3c9d4574754463ffd43373cf92133a;hp=d745065b1f6843d91e711ecfb4882fea0d991fdf;hpb=992092493a6c094605d83cd6c5823614f384a779;p=metaproxy-moved-to-github.git diff --git a/src/util.cpp b/src/util.cpp index d745065..c8cf573 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,4 +1,4 @@ -/* $Id: util.cpp,v 1.11 2006-01-18 14:10:47 adam Exp $ +/* $Id: util.cpp,v 1.12 2006-01-19 21:43:51 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -318,6 +318,39 @@ Z_APDU *yp2::odr::create_scanResponse(Z_APDU *in_apdu, return apdu; } +Z_GDU *yp2::odr::create_HTTP_Response(yp2::Session &session, + Z_HTTP_Request *hreq, int code) +{ + const char *response_version = "1.0"; + bool keepalive = false; + if (!strcmp(hreq->version, "1.0")) + { + const char *v = z_HTTP_header_lookup(hreq->headers, "Connection"); + if (v && !strcmp(v, "Keep-Alive")) + keepalive = true; + else + session.close(); + response_version = "1.0"; + } + else + { + const char *v = z_HTTP_header_lookup(hreq->headers, "Connection"); + if (v && !strcmp(v, "close")) + session.close(); + else + keepalive = true; + response_version = "1.1"; + } + + Z_GDU *gdu = z_get_HTTP_Response(m_odr, code); + Z_HTTP_Response *hres = gdu->u.HTTP_Response; + hres->version = odr_strdup(m_odr, response_version); + if (keepalive) + z_HTTP_header_add(m_odr, &hres->headers, "Connection", "Keep-Alive"); + + return gdu; +} + Z_ReferenceId **yp2::util::get_referenceId(Z_APDU *apdu) { switch (apdu->which)