def _discover_references(self, service, url): assert url[-1] == "/" url = urlparse.urljoin(url, "info/refs") headers = {} if self.dumb is not False: url += "?service=%s" % service.decode('ascii') headers["Content-Type"] = "application/x-%s-request" % ( service.decode('ascii')) resp = self._http_request(url, headers) try: content_type = resp.info().gettype() except AttributeError: content_type = resp.info().get_content_type() try: self.dumb = (not content_type.startswith("application/x-git-")) if not self.dumb: proto = Protocol(resp.read, None) # The first line should mention the service try: [pkt] = list(proto.read_pkt_seq()) except ValueError: raise GitProtocolError( "unexpected number of packets received") if pkt.rstrip(b'\n') != (b'# service=' + service): raise GitProtocolError( "unexpected first line %r from smart server" % pkt) return read_pkt_refs(proto) else: return read_info_refs(resp), set() finally: resp.close()
def _discover_references(self, service, url): assert url[-1] == "/" url = urlparse.urljoin(url, "info/refs") headers = {} if self.dumb is not False: url += "?service=%s" % service.decode('ascii') headers["Content-Type"] = "application/x-%s-request" % ( service.decode('ascii')) resp = self._http_request(url, headers) try: content_type = resp.info().gettype() except AttributeError: content_type = resp.info().get_content_type() try: self.dumb = (not content_type.startswith("application/x-git-")) if not self.dumb: proto = Protocol(resp.read, None) # The first line should mention the service pkts = list(proto.read_pkt_seq()) if pkts != [b'# service=' + service + b'\n']: raise GitProtocolError( "unexpected first line %r from smart server" % pkts) return read_pkt_refs(proto) else: return read_info_refs(resp), set() finally: resp.close()
def _load_check_ref(self, name, old_ref): self._check_refname(name) f = self.scon.get_object(self.filename) if not f: return {} refs = read_info_refs(f) if old_ref is not None: if refs[name] != old_ref: return False return refs
def _discover_references(self, service, url): assert url[-1] == "/" url = urlparse.urljoin(url, "info/refs") headers = {} if self.dumb != False: url += "?service=%s" % service headers["Content-Type"] = "application/x-%s-request" % service resp = self._http_request(url, headers) self.dumb = (not resp.info().gettype().startswith("application/x-git-")) if not self.dumb: proto = Protocol(resp.read, None) # The first line should mention the service pkts = list(proto.read_pkt_seq()) if pkts != [('# service=%s\n' % service)]: raise GitProtocolError( "unexpected first line %r from smart server" % pkts) return read_pkt_refs(proto) else: return read_info_refs(resp), set()