Fix HTTP headers.
authorZdeněk Salvet <salvet@ics.muni.cz>
Thu, 30 Aug 2007 15:37:46 +0000 (15:37 +0000)
committerZdeněk Salvet <salvet@ics.muni.cz>
Thu, 30 Aug 2007 15:37:46 +0000 (15:37 +0000)
org.glite.lb.server/src/lb_proto.c
org.glite.lb.server/src/lb_proto.h
org.glite.lb.server/src/srv_purge.c

index db59d31..db72568 100644 (file)
 #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
index aea3957..a90295d 100644 (file)
@@ -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)
index 53fb2db..a0d72a7 100644 (file)
@@ -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
 };