From 5c31ee75f228a720541ecea9655d109d451a8d08 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20Salvet?= Date: Thu, 30 Aug 2007 15:37:46 +0000 Subject: [PATCH] Fix HTTP headers. --- org.glite.lb.server/src/lb_proto.c | 24 +++++++++++++----------- org.glite.lb.server/src/lb_proto.h | 2 -- org.glite.lb.server/src/srv_purge.c | 3 +-- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/org.glite.lb.server/src/lb_proto.c b/org.glite.lb.server/src/lb_proto.c index db59d31..db72568 100644 --- a/org.glite.lb.server/src/lb_proto.c +++ b/org.glite.lb.server/src/lb_proto.c @@ -45,14 +45,20 @@ #define KEY_AGENT "User-Agent" -const char* const response_headers[] = { +static const char* const response_headers_dglb[] = { "Cache-Control: no-cache", - "Accept: application/x-dglb", - "User-Agent: edg_wll_Server/" PROTO_VERSION "/" COMP_PROTO, + "Server: edg_wll_Server/" PROTO_VERSION "/" COMP_PROTO, "Content-Type: application/x-dglb", NULL }; +static const char* const response_headers_html[] = { + "Cache-Control: no-cache", + "Server: edg_wll_Server/" PROTO_VERSION "/" COMP_PROTO, + "Content-Type: text/html", + NULL +}; + extern int edg_wll_NotifNewServer(edg_wll_Context, edg_wll_QueryRec const * const *, char const *, const edg_wll_NotifId, time_t *); @@ -366,7 +372,7 @@ edg_wll_ErrorCode edg_wll_ProtoV21(edg_wll_Context ctx, } else ret = HTTP_NOTALLOWED; errV21: asprintf(response,"HTTP/1.1 %d %s",ret,edg_wll_HTTPErrorMessage(ret)); - *headersOut = (char **) response_headers; + *headersOut = (char **) (html? response_headers_html : response_headers_dglb); if ((ret != HTTP_OK) && html) *bodyOut = edg_wll_ErrorToHTML(ctx,ret); else @@ -433,15 +439,13 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, flags = (requestPTR[1]=='?') ? edg_wll_string_to_stat_flags(requestPTR + 2) : 0; // FIXME: edg_wll_UserJobs should take flags as parameter - if (!ctx->peerName) { - edg_wll_SetError(ctx,EPERM,"Operation not permitted."); - ret = HTTP_UNAUTH; - } switch (edg_wll_UserJobs(ctx,&jobsOut,NULL)) { case 0: if (html) edg_wll_UserJobsToHTML(ctx, jobsOut, &message); else ret = HTTP_OK; break; case ENOENT: ret = HTTP_NOTFOUND; break; + case EPERM: ret = HTTP_UNAUTH; break; + case EDG_WLL_ERROR_NOINDEX: ret = HTTP_UNAVAIL; break; default: ret = HTTP_INTERNAL; break; } if (!html && (ret != HTTP_INTERNAL)) @@ -596,8 +600,6 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, } switch ( retCode ) { - // case EPERM : ret = HTTP_UNAUTH; - // /* soft-error fall through */ case 0: if (html) ret = HTTP_NOTIMPL; else ret = HTTP_OK; @@ -891,7 +893,7 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, } else ret = HTTP_NOTALLOWED; err: asprintf(response,"HTTP/1.1 %d %s",ret,edg_wll_HTTPErrorMessage(ret)); - *headersOut = (char **) response_headers; + *headersOut = (char **) (html ? response_headers_html : response_headers_dglb); if ((ret != HTTP_OK) && html) *bodyOut = edg_wll_ErrorToHTML(ctx,ret); else diff --git a/org.glite.lb.server/src/lb_proto.h b/org.glite.lb.server/src/lb_proto.h index aea3957..a90295d 100644 --- a/org.glite.lb.server/src/lb_proto.h +++ b/org.glite.lb.server/src/lb_proto.h @@ -5,8 +5,6 @@ #include "glite/lb/consumer.h" -extern const char* const response_headers[]; - /* Handle a single request of the LB server protocol * returns a complete response string (may contain a formatted error * message) diff --git a/org.glite.lb.server/src/srv_purge.c b/org.glite.lb.server/src/srv_purge.c index 53fb2db..a0d72a7 100644 --- a/org.glite.lb.server/src/srv_purge.c +++ b/org.glite.lb.server/src/srv_purge.c @@ -38,8 +38,7 @@ static const char* const resp_headers[] = { "Cache-Control: no-cache", - "Accept: application/x-dglb", - "User-Agent: edg_wll_Server/" PROTO_VERSION "/" COMP_PROTO, + "Server: edg_wll_Server/" PROTO_VERSION "/" COMP_PROTO, "Content-Type: application/x-dglb", NULL }; -- 1.8.2.3