def _post_request(self): """HTTP GET request parser """ # check if input file size was not exceeded maxsize = configuration.get_config_value('server', 'maxrequestsize') maxsize = configuration.get_size_mb(maxsize) * 1024 * 1024 if self.http_request.content_length > maxsize: raise FileSizeExceeded( 'File size for input exceeded.' ' Maximum request size allowed: {} megabytes'.format( maxsize / 1024 / 1024)) try: doc = lxml.etree.fromstring(self.http_request.get_data()) except Exception as e: if PY2: raise NoApplicableCode(e.message) else: raise NoApplicableCode(e.msg) operation = doc.tag version = get_version_from_ns(doc.nsmap[doc.prefix]) self.set_version(version) request_parser = self._post_request_parser(operation) request_parser(doc)
def max_input_size(): """Calculates maximal size for input file based on configuration and units. :return: maximum file size in bytes """ ms = config.get_config_value('server', 'maxsingleinputsize') return config.get_size_mb(ms) * 1024**2
def calculate_max_input_size(self): """Calculates maximal size for input file based on configuration and units :return: maximum file size bytes """ max_size = configuration.get_config_value('server', 'maxsingleinputsize') self.max_size = configuration.get_size_mb(max_size)
def calculate_max_input_size(self): """Calculates maximal size for input file based on configuration and units :return: maximum file size bytes """ max_size = configuration.get_config_value( 'server', 'maxsingleinputsize') self.max_size = configuration.get_size_mb(max_size)
def _construct_doc(self): if not self.identifiers: raise MissingParameterValue('Missing parameter value "identifier"', 'identifier') template = self.template_env.get_template(self.version + '/describe/main.xml') max_size = int(config.get_size_mb(config.get_config_value('server', 'maxsingleinputsize'))) doc = template.render(max_size=max_size, **self.json) return doc
def _post_request(self): """HTTP GET request parser """ # check if input file size was not exceeded maxsize = configuration.get_config_value('server', 'maxrequestsize') maxsize = configuration.get_size_mb(maxsize) * 1024 * 1024 if self.http_request.content_length > maxsize: raise FileSizeExceeded('File size for input exceeded.' ' Maximum request size allowed: %i megabytes' % maxsize / 1024 / 1024) try: doc = lxml.etree.fromstring(self.http_request.get_data()) except Exception as e: if PY2: raise NoApplicableCode(e.message) else: raise NoApplicableCode(e.msg) operation = doc.tag request_parser = self._post_request_parser(operation) request_parser(doc)