buildbot / buildbot

@@ -39,7 +39,7 @@
Loading
39 39
        if self.gql_config is not None:
40 40
            try:
41 41
                import graphql
42 -
            except ImportError:
42 +
            except ImportError:  # pragma: no cover
43 43
                raise ImportError(
44 44
                    "graphql is enabled but 'graphql-core' is not installed"
45 45
                )
@@ -78,7 +78,20 @@
Loading
78 78
79 79
        # graphql accepts its query either in post data or get query
80 80
        if request.method == b"POST":
81 -
            query = request.content.read()
81 +
            content_type = request.getHeader(b"content-type")
82 +
            if content_type == b"application/graphql":
83 +
                query = request.content.read().decode()
84 +
            elif content_type == b"application/json":
85 +
                json_query = json.load(request.content)
86 +
                query = json_query.pop('query')
87 +
                if json_query:
88 +
                    fields = " ".join(json_query.keys())
89 +
                    raise Error(400, b"json request unsupported fields: " + fields.encode())
90 +
            elif content_type is None:
91 +
                raise Error(400, b"no content-type")
92 +
            else:
93 +
                raise Error(400, b"unsupported content-type: " + content_type)
94 +
82 95
        elif request.method in (b"GET"):
83 96
            if b"query" not in request.args:
84 97
                raise Error(400, b"GET request must contain a 'query' parameter")
@@ -89,4 +102,5 @@
Loading
89 102
        res = yield self.renderQuery(query)
90 103
        return res
91 104
105 +
92 106
RestRootResource.addApiVersion(3, V3RootResource)
Files Coverage
master/buildbot 92.25%
worker/buildbot_worker 85.54%
Project Totals (341 files) 91.84%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading