diff --git a/TAP/tap.py b/TAP/tap.py index cc20103..0f73ba4 100755 --- a/TAP/tap.py +++ b/TAP/tap.py @@ -542,6 +542,21 @@ def __init__(self, **kwargs): self.statdict['resulturl'] = '' + # + #{ availability and capabilities are static VOSI documents: they need + # no workspace, so answer them before workspace resolution. Going + # through it treated the empty jobid as a workspace name and failed + # with a 500 whenever /TAP did not already exist. + # + if (self.tapcontext == 'availability'): + self.__printVosiAvailability__ () + + if (self.tapcontext == 'capabilities'): + self.__printVosiCapability__ () + # + #} end VOSI static endpoints + # + # # sync or async without input workspace id: make workspace, # otherwise retrieve workspace from getstatus id @@ -632,16 +647,6 @@ def __init__(self, **kwargs): logging.debug(f'workspace = {self.workspace:s}') logging.debug(f'userWorkdir = {self.userWorkdir:s}') - # - #{ if tapcontext is one of vosiEnpoint, take care of take care of VOSI - # output and return - # - if (self.tapcontext == 'availability'): - self.__printVosiAvailability__ () - - if (self.tapcontext == 'capabilities'): - self.__printVosiCapability__ () - # # vositable: make up vositbl filepath # @@ -1900,7 +1905,7 @@ def __printStatus__(self, key, retval, outtype, **kwargs): if(outtype == 'xml'): - print("Content-type: text/xml\r") + print("Content-type: application/xml\r") print("\r") print('') @@ -2000,7 +2005,7 @@ def __getStatus__(self, workdir, workspace, key, param, **kwargs): if(len(key) == 0): print("HTTP/1.1 200 OK\r") - print("Content-type: text/xml\r") + print("Content-type: application/xml\r") print("\r") print(data) sys.exit() @@ -2256,7 +2261,7 @@ def __getStatus__(self, workdir, workspace, key, param, **kwargs): if(format == 'json'): print("Content-type: application/json\r") elif(format == 'votable'): - print("Content-type: text/xml\r") + print("Content-type: application/xml\r") else: print("Content-type: text/plain\r") print("\r") @@ -2305,7 +2310,7 @@ def __printError__(self, fmt, errmsg, errcode): print(httphdr) - print("Content-type: text/xml\r") + print("Content-type: application/xml\r") print("\r") print('') @@ -2323,7 +2328,7 @@ def __printError__(self, fmt, errmsg, errcode): """ if(fmt == 'votable'): - print("Content-type: text/xml\r") + print("Content-type: application/xml\r") print("\r") print('') @@ -2427,7 +2432,7 @@ def __printSyncResult__(self, resultpath, format, **kwargs): if(format == 'json'): print("Content-type: application/json\r") elif(format == 'votable'): - print("Content-type: text/xml\r") + print("Content-type: application/xml\r") else: print("Content-type: text/plain\r") print("\r") @@ -2820,6 +2825,20 @@ def __printVosiAvailability__ (self, **kwargs): # { printVosiAvailability # + # + # nph- CGI: emit the full HTTP response ourselves. The status + # line and each header must end in CRLF, and a bare CRLF line + # closes the header block -- nginx and Cloudflare reject the + # response otherwise. The terminator is spelled out via end= + # rather than a trailing \r leaning on print's implicit \n, + # so the CRLF requirement is visible at a glance. + # + + print ('HTTP/1.1 200 OK', end='\r\n') + print ('Content-type: application/xml', end='\r\n') + print ('Connection: close', end='\r\n') + print ('', end='\r\n') + print ('') print ('') print ('true') print (' TAP service available.') print ('') + print (end='\r\n') sys.exit() @@ -2843,6 +2863,20 @@ def __printVosiCapability__ (self, **kwargs): # { printVosiCapability # + # + # nph- CGI: emit the full HTTP response ourselves. The status + # line and each header must end in CRLF, and a bare CRLF line + # closes the header block -- nginx and Cloudflare reject the + # response otherwise. The terminator is spelled out via end= + # rather than a trailing \r leaning on print's implicit \n, + # so the CRLF requirement is visible at a glance. + # + + print ('HTTP/1.1 200 OK', end='\r\n') + print ('Content-type: application/xml', end='\r\n') + print ('Connection: close', end='\r\n') + print (end='\r\n') + print ('') print ('') print ('') print ('') print ('') + print (end='\r\n') sys.exit()