Skip to content

Commit

Permalink
Merge pull request buildbot#8067 from tdesveaux/remove-deprecated-cgi
Browse files Browse the repository at this point in the history
rest: remove usage of deprecated cgi module
  • Loading branch information
p12tic authored Oct 1, 2024
2 parents bad03b5 + c9b77d6 commit dcc0e6b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions master/buildbot/www/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from __future__ import annotations

import cgi
import datetime
import fnmatch
import json
Expand Down Expand Up @@ -57,12 +56,13 @@ def __init__(self, message, jsonrpccode):


class ContentTypeParser:
def __init__(self, contenttype):
def __init__(self, contenttype: str | bytes | None) -> None:
self.typeheader = contenttype

def gettype(self):
mimetype, _ = cgi.parse_header(bytes2unicode(self.typeheader))
return mimetype
def gettype(self) -> str | None:
if self.typeheader is None:
return None
return bytes2unicode(self.typeheader).split(';', 1)[0]


URL_ENCODED = b"application/x-www-form-urlencoded"
Expand Down Expand Up @@ -191,7 +191,7 @@ def handleErrors(self, writeError):

# JSONRPC2 support

def decodeJsonRPC2(self, request):
def decodeJsonRPC2(self, request: server.Request):
# Verify the content-type. Browsers are easily convinced to send
# POST data to arbitrary URLs via 'form' elements, but they won't
# use the application/json content-type.
Expand Down

0 comments on commit dcc0e6b

Please sign in to comment.