@@ -46,10 +46,25 @@ def do_OPTIONS(self):
46
46
request_headers [header [0 ]] = header [1 ]
47
47
self .wfile .write ("" )
48
48
49
- def common_handler (self ):
49
+ """
50
+ - 1xx: Informational - Request received, continuing process
51
+ - 2xx: Success - The action was successfully received,
52
+ understood, and accepted
53
+ - 3xx: Redirection - Further action must be taken in order to
54
+ complete the request
55
+ - 4xx: Client Error - The request contains bad syntax or cannot
56
+ be fulfilled
57
+ - 5xx: Server Error - The server failed to fulfill an apparently
58
+ valid request
59
+ """
60
+
61
+ def setStatusCode (self ):
50
62
# self.send_response(HTTPStatus.FORBIDDEN)
51
- # self.send_response(HTTPStatus.INTERNAL_SERVER_ERROR)
52
- self .send_response (HTTPStatus .OK )
63
+ self .send_response (HTTPStatus .INTERNAL_SERVER_ERROR , "Wolaaa" )
64
+ # self.send_response(HTTPStatus.OK)
65
+
66
+ def common_handler (self ):
67
+ self .setStatusCode ()
53
68
# print(self.path)
54
69
auth_params = self .decodeAuthHeader ()
55
70
"""
@@ -112,10 +127,11 @@ def run():
112
127
"""
113
128
114
129
def getBody (self ):
130
+ blocking = False
115
131
content_length = int (self .headers .get ("content-length" , - 1 ))
116
132
content_type = self .headers .get ("content-type" , - 1 )
117
133
method = self .command
118
- if content_length == - 1 and method in ["POST" , "PUT" , "PATCH" ] and content_type != - 1 :
134
+ if blocking and content_length == - 1 and method in ["POST" , "PUT" , "PATCH" ] and content_type != - 1 :
119
135
# Just giving a try here, The `content-length` header could be missing in case of HTTP1.1 chunked transfer encoding state
120
136
# So giving it a try, If there is no data while satisfying the above condition , the rfile.readline() will hang!!!
121
137
request_body = ""
@@ -125,7 +141,7 @@ def getBody(self):
125
141
break
126
142
request_body += line
127
143
return request_body
128
- return None if content_length == 0 else self .rfile .read (content_length ).decode ("UTF-8" )
144
+ return None if content_length in [ 0 , - 1 ] else self .rfile .read (content_length ).decode ("UTF-8" )
129
145
130
146
def getDigestAuth (self ):
131
147
www_authenticate_header = python_digest .build_digest_challenge (
0 commit comments