Пример #1
0
 def print_requests(self, reqs, respdump, reqdump, fp=sys.stdout):
     """
         Performs a series of requests, and prints results to the specified
         file pointer.
     """
     for i in reqs:
         try:
             r = rparse.parse_request(self.settings, i)
             req = r.serve(self.wfile, None, self.host)
             if reqdump:
                 print >> fp, "\n>>", req["method"], repr(req["path"])
                 for a in req["actions"]:
                     print >> fp, "\t",
                     for x in a:
                         print >> fp, x,
                     print >> fp
             self.wfile.flush()
             resp = http.read_response(self.rfile, r.method, None)
         except rparse.ParseException, v:
             print >> fp, "Error parsing request spec: %s"%v.msg
             print >> fp, v.marked()
             return
         except rparse.FileAccessDenied, v:
             print >> fp, "File access error: %s"%v
             return
Пример #2
0
def _preview(is_request):
    if is_request:
        template = "request_preview.html"
    else:
        template = "response_preview.html"

    spec = request.args["spec"]

    args = dict(
        spec = spec,
        section = "main",
        syntaxerror = None,
        error = None,
        pauses = None
    )
    if not spec.strip():
        args["error"] = "Can't parse an empty spec."
        return render(template, False, **args)

    try:
        if is_request:
            r = rparse.parse_request(app.config["pathod"].request_settings, spec)
        else:
            r = rparse.parse_response(app.config["pathod"].request_settings, spec)
    except rparse.ParseException, v:
        args["syntaxerror"] = str(v)
        args["marked"] = v.marked()
        return render(template, False, **args)
Пример #3
0
    def print_request(self,
                      spec,
                      showreq,
                      showresp,
                      explain,
                      hexdump,
                      ignorecodes,
                      ignoretimeout,
                      fp=sys.stdout):
        """
            Performs a series of requests, and prints results to the specified
            file descriptor.

            spec: A request specification
            showreq: Print requests
            showresp: Print responses
            explain: Print request explanation
            hexdump: When printing requests or responses, use hex dump output
            ignorecodes: Sequence of return codes to ignore

            Returns True if we have a non-ignored response.
        """
        try:
            r = rparse.parse_request(self.settings, spec)
        except rparse.ParseException, v:
            print >> fp, "Error parsing request spec: %s" % v.msg
            print >> fp, v.marked()
            return
Пример #4
0
def _preview(is_request):
    if is_request:
        template = "request_preview.html"
    else:
        template = "response_preview.html"

    spec = request.args["spec"]

    args = dict(
        spec = spec,
        section = "main",
        syntaxerror = None,
        error = None,
        pauses = None
    )
    if not spec.strip():
        args["error"] = "Can't parse an empty spec."
        return render(template, False, **args)

    try:
        if is_request:
            r = rparse.parse_request(app.config["pathod"].request_settings, spec)
        else:
            r = rparse.parse_response(app.config["pathod"].request_settings, spec)
    except rparse.ParseException, v:
        args["syntaxerror"] = str(v)
        args["marked"] = v.marked()
        return render(template, False, **args)
Пример #5
0
    def request(self, spec):
        """
            Return an (httpversion, code, msg, headers, content) tuple.

            May raise rparse.ParseException, netlib.http.HttpError or
            rparse.FileAccessDenied.
        """
        r = rparse.parse_request(self.settings, spec)
        ret = r.serve(self.wfile, None, self.host)
        self.wfile.flush()
        return http.read_response(self.rfile, r.method, None)
Пример #6
0
    def request(self, spec):
        """
            Return an (httpversion, code, msg, headers, content) tuple.

            May raise rparse.ParseException, netlib.http.HttpError or
            rparse.FileAccessDenied.
        """
        r = rparse.parse_request(self.settings, spec)
        ret = r.serve(self.wfile, None, self.host)
        self.wfile.flush()
        return http.read_response(self.rfile, r.method, None)
Пример #7
0
    def print_request(self, spec, showreq, showresp, explain, hexdump, ignorecodes, ignoretimeout, fp=sys.stdout):
        """
            Performs a series of requests, and prints results to the specified
            file descriptor.

            spec: A request specification
            showreq: Print requests
            showresp: Print responses
            explain: Print request explanation
            hexdump: When printing requests or responses, use hex dump output
            ignorecodes: Sequence of return codes to ignore

            Returns True if we have a non-ignored response.
        """
        try:
            r = rparse.parse_request(self.settings, spec)
        except rparse.ParseException, v:
            print >> fp, "Error parsing request spec: %s"%v.msg
            print >> fp, v.marked()
            return