summarylogtreecommitdiffstats
path: root/18131.patch
blob: abb2bc765201d6125c11442e5e63e217258b034d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
diff --git a/xbmc/network/WebServer.cpp b/xbmc/network/WebServer.cpp
index 7834042..a1c6923 100644
--- a/xbmc/network/WebServer.cpp
+++ b/xbmc/network/WebServer.cpp
@@ -36,14 +36,18 @@
 
 #define MAX_POST_BUFFER_SIZE 2048
 
-#define PAGE_FILE_NOT_FOUND "<html><head><title>File not found</title></head><body>File not found</body></html>"
-#define NOT_SUPPORTED       "<html><head><title>Not Supported</title></head><body>The method you are trying to use is not supported by this server</body></html>"
+#define PAGE_FILE_NOT_FOUND \
+  "<html><head><title>File not found</title></head><body>File not found</body></html>"
+#define NOT_SUPPORTED \
+  "<html><head><title>Not Supported</title></head><body>The method you are trying to use is not " \
+  "supported by this server</body></html>"
 
 #define HEADER_VALUE_NO_CACHE "no-cache"
 
-#define HEADER_NEWLINE        "\r\n"
+#define HEADER_NEWLINE "\r\n"
 
-typedef struct {
+typedef struct
+{
   std::shared_ptr<XFILE::CFile> file;
   CHttpRanges ranges;
   size_t rangeCountTotal;
@@ -62,7 +66,7 @@ CWebServer::CWebServer()
     m_cert()
 {
 #if defined(TARGET_DARWIN)
-  void *stack_addr;
+  void* stack_addr;
   pthread_attr_t attr;
   pthread_attr_init(&attr);
   pthread_attr_getstack(&attr, &stack_addr, &m_thread_stacksize);
@@ -86,16 +90,16 @@ static MHD_Response* create_response(size_t size, const void* data, int free, in
   return MHD_create_response_from_buffer(size, const_cast<void*>(data), mode);
 }
 
-int CWebServer::AskForAuthentication(const HTTPRequest& request) const
+MHD_RESULT CWebServer::AskForAuthentication(const HTTPRequest& request) const
 {
-  struct MHD_Response *response = create_response(0, nullptr, MHD_NO, MHD_NO);
+  struct MHD_Response* response = create_response(0, nullptr, MHD_NO, MHD_NO);
   if (!response)
   {
     CLog::Log(LOGERROR, "CWebServer[%hu]: unable to create HTTP Unauthorized response", m_port);
     return MHD_NO;
   }
 
-  int ret = AddHeader(response, MHD_HTTP_HEADER_CONNECTION, "close");
+  MHD_RESULT ret = AddHeader(response, MHD_HTTP_HEADER_CONNECTION, "close");
   if (!ret)
   {
     CLog::Log(LOGERROR, "CWebServer[%hu]: unable to prepare HTTP Unauthorized response", m_port);
@@ -105,7 +109,10 @@ int CWebServer::AskForAuthentication(const HTTPRequest& request) const
 
   LogResponse(request, MHD_HTTP_UNAUTHORIZED);
 
-  ret = MHD_queue_basic_auth_fail_response(request.connection, "XBMC", response);
+  // This MHD_RESULT cast is only necessary for libmicrohttpd 0.9.71
+  // The return type of MHD_queue_basic_auth_fail_response was fixed for future versions
+  // See https://git.gnunet.org/libmicrohttpd.git/commit/?id=860b42e9180da4dcd7e8690a3fcdb4e37e5772c5
+  ret = (MHD_RESULT) MHD_queue_basic_auth_fail_response(request.connection, "XBMC", response);
   MHD_destroy_response(response);
 
   return ret;
@@ -135,10 +142,14 @@ bool CWebServer::IsAuthenticated(const HTTPRequest& request) const
   return authenticated;
 }
 
-int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection,
-                      const char *url, const char *method,
-                      const char *version, const char *upload_data,
-                      size_t *upload_data_size, void **con_cls)
+MHD_RESULT CWebServer::AnswerToConnection(void* cls,
+                                          struct MHD_Connection* connection,
+                                          const char* url,
+                                          const char* method,
+                                          const char* version,
+                                          const char* upload_data,
+                                          size_t* upload_data_size,
+                                          void** con_cls)
 {
   if (cls == nullptr || con_cls == nullptr || *con_cls == nullptr)
   {
@@ -146,7 +157,7 @@ int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection,
     return MHD_NO;
   }
 
-  CWebServer *webServer = reinterpret_cast<CWebServer*>(cls);
+  CWebServer* webServer = reinterpret_cast<CWebServer*>(cls);
   if (webServer == nullptr)
   {
     CLog::Log(LOGERROR, "CWebServer[unknown]: invalid request received");
@@ -155,15 +166,22 @@ int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection,
 
   ConnectionHandler* connectionHandler = reinterpret_cast<ConnectionHandler*>(*con_cls);
   HTTPMethod methodType = GetHTTPMethod(method);
-  HTTPRequest request = { webServer, connection, connectionHandler->fullUri, url, methodType, version };
+  HTTPRequest request = {webServer, connection, connectionHandler->fullUri,
+                         url,       methodType, version};
 
   if (connectionHandler->isNew)
     webServer->LogRequest(request);
 
-  return webServer->HandlePartialRequest(connection, connectionHandler, request, upload_data, upload_data_size, con_cls);
+  return webServer->HandlePartialRequest(connection, connectionHandler, request, upload_data,
+                                         upload_data_size, con_cls);
 }
 
-int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, ConnectionHandler* connectionHandler, const HTTPRequest& request, const char *upload_data, size_t *upload_data_size, void **con_cls)
+MHD_RESULT CWebServer::HandlePartialRequest(struct MHD_Connection* connection,
+                                            ConnectionHandler* connectionHandler,
+                                            const HTTPRequest& request,
+                                            const char* upload_data,
+                                            size_t* upload_data_size,
+                                            void** con_cls)
 {
   std::unique_ptr<ConnectionHandler> conHandler(connectionHandler);
 
@@ -196,17 +214,18 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
           if (handler->GetLastModifiedDate(lastModified) && lastModified.IsValid())
           {
             // handle If-Modified-Since or If-Unmodified-Since
-            std::string ifModifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_MODIFIED_SINCE);
-            std::string ifUnmodifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE);
+            std::string ifModifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(
+                connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_MODIFIED_SINCE);
+            std::string ifUnmodifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(
+                connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE);
 
             CDateTime ifModifiedSinceDate;
             CDateTime ifUnmodifiedSinceDate;
             // handle If-Modified-Since (but only if the response is cacheable)
-            if (cacheable &&
-              ifModifiedSinceDate.SetFromRFC1123DateTime(ifModifiedSince) &&
-              lastModified.GetAsUTCDateTime() <= ifModifiedSinceDate)
+            if (cacheable && ifModifiedSinceDate.SetFromRFC1123DateTime(ifModifiedSince) &&
+                lastModified.GetAsUTCDateTime() <= ifModifiedSinceDate)
             {
-              struct MHD_Response *response = create_response(0, nullptr, MHD_NO, MHD_NO);
+              struct MHD_Response* response = create_response(0, nullptr, MHD_NO, MHD_NO);
               if (response == nullptr)
               {
                 CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP 304 response", m_port);
@@ -217,7 +236,7 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
             }
             // handle If-Unmodified-Since
             else if (ifUnmodifiedSinceDate.SetFromRFC1123DateTime(ifUnmodifiedSince) &&
-              lastModified.GetAsUTCDateTime() > ifUnmodifiedSinceDate)
+                     lastModified.GetAsUTCDateTime() > ifUnmodifiedSinceDate)
               return SendErrorResponse(request, MHD_HTTP_PRECONDITION_FAILED, request.method);
           }
 
@@ -231,7 +250,8 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
         // as ownership of the connection handler is passed to libmicrohttpd we must not destroy it
         SetupPostDataProcessing(request, conHandler.get(), handler, con_cls);
 
-        // as ownership of the connection handler has been passed to libmicrohttpd we must not destroy it
+        // as ownership of the connection handler has been passed to libmicrohttpd we must not
+        // destroy it
         conHandler.release();
 
         return MHD_YES;
@@ -249,7 +269,8 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
       // process additional / remaining POST data
       if (ProcessPostData(request, conHandler.get(), upload_data, upload_data_size, con_cls))
       {
-        // as ownership of the connection handler has been passed to libmicrohttpd we must not destroy it
+        // as ownership of the connection handler has been passed to libmicrohttpd we must not
+        // destroy it
         conHandler.release();
 
         return MHD_YES;
@@ -266,7 +287,8 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
       return HandleRequest(conHandler->requestHandler);
     }
 
-    // it's unusual to get more than one call to AnswerToConnection for none-POST requests, but let's handle it anyway
+    // it's unusual to get more than one call to AnswerToConnection for none-POST requests, but
+    // let's handle it anyway
     auto requestHandler = FindRequestHandler(request);
     if (requestHandler != nullptr)
       return HandleRequest(requestHandler);
@@ -276,15 +298,20 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti
   return SendErrorResponse(request, MHD_HTTP_NOT_FOUND, request.method);
 }
 
-int CWebServer::HandlePostField(void *cls, enum MHD_ValueKind kind, const char *key,
-                                const char *filename, const char *content_type,
-                                const char *transfer_encoding, const char *data, uint64_t off,
-                                size_t size)
+MHD_RESULT CWebServer::HandlePostField(void* cls,
+                                       enum MHD_ValueKind kind,
+                                       const char* key,
+                                       const char* filename,
+                                       const char* content_type,
+                                       const char* transfer_encoding,
+                                       const char* data,
+                                       uint64_t off,
+                                       size_t size)
 {
-  ConnectionHandler *conHandler = (ConnectionHandler *)cls;
+  ConnectionHandler* conHandler = (ConnectionHandler*)cls;
 
-  if (conHandler == nullptr || conHandler->requestHandler == nullptr ||
-      key == nullptr || data == nullptr || size == 0)
+  if (conHandler == nullptr || conHandler->requestHandler == nullptr || key == nullptr ||
+      data == nullptr || size == 0)
   {
     CLog::Log(LOGERROR, "CWebServer: unable to handle HTTP POST field");
     return MHD_NO;
@@ -294,21 +321,21 @@ int CWebServer::HandlePostField(void *cls, enum MHD_ValueKind kind, const char *
   return MHD_YES;
 }
 
-int CWebServer::HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handler)
+MHD_RESULT CWebServer::HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handler)
 {
   if (handler == nullptr)
     return MHD_NO;
 
   HTTPRequest request = handler->GetRequest();
-  int ret = handler->HandleRequest();
+  MHD_RESULT ret = handler->HandleRequest();
   if (ret == MHD_NO)
   {
     CLog::Log(LOGERROR, "CWebServer[%hu]: failed to handle HTTP request for %s", m_port, request.pathUrl.c_str());
     return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method);
   }
 
-  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
-  struct MHD_Response *response = nullptr;
+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
+  struct MHD_Response* response = nullptr;
   switch (responseDetails.type)
   {
     case HTTPNone:
@@ -331,7 +358,8 @@ int CWebServer::HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handle
       break;
 
     case HTTPError:
-      ret = CreateErrorResponse(request.connection, responseDetails.status, request.method, response);
+      ret =
+          CreateErrorResponse(request.connection, responseDetails.status, request.method, response);
       break;
 
     default:
@@ -348,13 +376,15 @@ int CWebServer::HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handle
   return FinalizeRequest(handler, responseDetails.status, response);
 }
 
-int CWebServer::FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& handler, int responseStatus, struct MHD_Response *response)
+MHD_RESULT CWebServer::FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& handler,
+                                       int responseStatus,
+                                       struct MHD_Response* response)
 {
   if (handler == nullptr || response == nullptr)
     return MHD_NO;
 
-  const HTTPRequest &request = handler->GetRequest();
-  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
+  const HTTPRequest& request = handler->GetRequest();
+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
 
   // if the request handler has set a content type and it hasn't been set as a header, add it
   if (!responseDetails.contentType.empty())
@@ -380,7 +410,8 @@ int CWebServer::FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& hand
 
     // if the response can't be cached or the maximum age is 0 force the client not to cache
     if (!handler->CanBeCached() || maxAge == 0)
-      handler->AddResponseHeader(MHD_HTTP_HEADER_CACHE_CONTROL, "private, max-age=0, " HEADER_VALUE_NO_CACHE);
+      handler->AddResponseHeader(MHD_HTTP_HEADER_CACHE_CONTROL,
+                                 "private, max-age=0, " HEADER_VALUE_NO_CACHE);
     else
     {
       // create the value of the Cache-Control header
@@ -416,14 +447,14 @@ int CWebServer::FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& hand
   return SendResponse(request, responseStatus, response);
 }
 
-std::shared_ptr<IHTTPRequestHandler> CWebServer::FindRequestHandler(const HTTPRequest& request) const
+std::shared_ptr<IHTTPRequestHandler> CWebServer::FindRequestHandler(
+    const HTTPRequest& request) const
 {
   // look for a IHTTPRequestHandler which can take care of the current request
   auto requestHandlerIt = std::find_if(m_requestHandlers.cbegin(), m_requestHandlers.cend(),
-    [&request](const IHTTPRequestHandler* requestHandler)
-    {
-      return requestHandler->CanHandleRequest(request);
-    });
+                                       [&request](const IHTTPRequestHandler* requestHandler) {
+                                         return requestHandler->CanHandleRequest(request);
+                                       });
 
   // we found a matching IHTTPRequestHandler so let's get a new instance for this request
   if (requestHandlerIt != m_requestHandlers.cend())
@@ -435,7 +466,8 @@ std::shared_ptr<IHTTPRequestHandler> CWebServer::FindRequestHandler(const HTTPRe
 bool CWebServer::IsRequestCacheable(const HTTPRequest& request) const
 {
   // handle Cache-Control
-  std::string cacheControl = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CACHE_CONTROL);
+  std::string cacheControl = HTTPRequestHandlerUtils::GetRequestHeaderValue(
+      request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CACHE_CONTROL);
   if (!cacheControl.empty())
   {
     std::vector<std::string> cacheControls = StringUtils::Split(cacheControl, ",");
@@ -450,23 +482,26 @@ bool CWebServer::IsRequestCacheable(const HTTPRequest& request) const
   }
 
   // handle Pragma
-  std::string pragma = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_PRAGMA);
+  std::string pragma = HTTPRequestHandlerUtils::GetRequestHeaderValue(
+      request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_PRAGMA);
   if (pragma.compare(HEADER_VALUE_NO_CACHE) == 0)
     return false;
 
   return true;
 }
 
-bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime &lastModified) const
+bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime& lastModified) const
 {
   // parse the Range header and store it in the request object
   CHttpRanges ranges;
-  bool ranged = ranges.Parse(HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE));
+  bool ranged = ranges.Parse(HTTPRequestHandlerUtils::GetRequestHeaderValue(
+      request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE));
 
   // handle If-Range header but only if the Range header is present
   if (ranged && lastModified.IsValid())
   {
-    std::string ifRange = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_RANGE);
+    std::string ifRange = HTTPRequestHandlerUtils::GetRequestHeaderValue(
+        request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_RANGE);
     if (!ifRange.empty() && lastModified.IsValid())
     {
       CDateTime ifRangeDate;
@@ -482,25 +517,33 @@ bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime &la
   return !ranges.IsEmpty();
 }
 
-void CWebServer::SetupPostDataProcessing(const HTTPRequest& request, ConnectionHandler *connectionHandler, std::shared_ptr<IHTTPRequestHandler> handler, void **con_cls) const
+void CWebServer::SetupPostDataProcessing(const HTTPRequest& request,
+                                         ConnectionHandler* connectionHandler,
+                                         std::shared_ptr<IHTTPRequestHandler> handler,
+                                         void** con_cls) const
 {
   connectionHandler->requestHandler = handler;
 
-  // we might need to handle the POST data ourselves which is done in the next call to AnswerToConnection
+  // we might need to handle the POST data ourselves which is done in the next call to
+  // AnswerToConnection
   *con_cls = connectionHandler;
 
   // get the content-type of the POST data
-  const auto contentType = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE);
+  const auto contentType = HTTPRequestHandlerUtils::GetRequestHeaderValue(
+      request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE);
   if (contentType.empty())
     return;
 
-  // if the content-type is neither application/x-ww-form-urlencoded nor multipart/form-data we need to handle it ourselves
+  // if the content-type is neither application/x-ww-form-urlencoded nor multipart/form-data we need
+  // to handle it ourselves
   if (!StringUtils::EqualsNoCase(contentType, MHD_HTTP_POST_ENCODING_FORM_URLENCODED) &&
       !StringUtils::EqualsNoCase(contentType, MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA))
     return;
 
   // otherwise we can use MHD's POST processor
-  connectionHandler->postprocessor = MHD_create_post_processor(request.connection, MAX_POST_BUFFER_SIZE, &CWebServer::HandlePostField, static_cast<void*>(connectionHandler));
+  connectionHandler->postprocessor = MHD_create_post_processor(
+      request.connection, MAX_POST_BUFFER_SIZE, &CWebServer::HandlePostField,
+      static_cast<void*>(connectionHandler));
 
   // MHD doesn't seem to be able to handle this post request
   if (connectionHandler->postprocessor == nullptr)
@@ -510,7 +553,11 @@ void CWebServer::SetupPostDataProcessing(const HTTPRequest& request, ConnectionH
   }
 }
 
-bool CWebServer::ProcessPostData(const HTTPRequest& request, ConnectionHandler *connectionHandler, const char *upload_data, size_t *upload_data_size, void **con_cls) const
+bool CWebServer::ProcessPostData(const HTTPRequest& request,
+                                 ConnectionHandler* connectionHandler,
+                                 const char* upload_data,
+                                 size_t* upload_data_size,
+                                 void** con_cls) const
 {
   if (connectionHandler->requestHandler == nullptr)
   {
@@ -531,10 +578,12 @@ bool CWebServer::ProcessPostData(const HTTPRequest& request, ConnectionHandler *
     bool postDataHandled = false;
     // either use MHD's POST processor
     if (connectionHandler->postprocessor != nullptr)
-      postDataHandled = MHD_post_process(connectionHandler->postprocessor, upload_data, *upload_data_size) == MHD_YES;
+      postDataHandled = MHD_post_process(connectionHandler->postprocessor, upload_data,
+                                         *upload_data_size) == MHD_YES;
     // or simply copy the data to the handler
     else if (connectionHandler->requestHandler != nullptr)
-      postDataHandled = connectionHandler->requestHandler->AddPostData(upload_data, *upload_data_size);
+      postDataHandled =
+          connectionHandler->requestHandler->AddPostData(upload_data, *upload_data_size);
 
     // abort if the received POST data couldn't be handled
     if (!postDataHandled)
@@ -554,7 +603,7 @@ bool CWebServer::ProcessPostData(const HTTPRequest& request, ConnectionHandler *
   return true;
 }
 
-void CWebServer::FinalizePostDataProcessing(ConnectionHandler *connectionHandler) const
+void CWebServer::FinalizePostDataProcessing(ConnectionHandler* connectionHandler) const
 {
   if (connectionHandler->postprocessor == nullptr)
     return;
@@ -562,13 +611,14 @@ void CWebServer::FinalizePostDataProcessing(ConnectionHandler *connectionHandler
   MHD_destroy_post_processor(connectionHandler->postprocessor);
 }
 
-int CWebServer::CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const
+MHD_RESULT CWebServer::CreateMemoryDownloadResponse(
+    const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response*& response) const
 {
   if (handler == nullptr)
     return MHD_NO;
 
-  const HTTPRequest &request = handler->GetRequest();
-  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
+  const HTTPRequest& request = handler->GetRequest();
+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
   HttpResponseRanges responseRanges = handler->GetResponseData();
 
   // check if the response is completely empty
@@ -577,7 +627,7 @@ int CWebServer::CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestH
 
   // check if the response contains more ranges than the request asked for
   if ((request.ranges.IsEmpty() && responseRanges.size() > 1) ||
-     (!request.ranges.IsEmpty() && responseRanges.size() > request.ranges.Size()))
+      (!request.ranges.IsEmpty() && responseRanges.size() > request.ranges.Size()))
   {
     CLog::Log(LOGWARNING, "CWebServer[%hu]: response contains more ranges (%d) than the request asked for (%d)", m_port, (int)responseRanges.size(), (int)request.ranges.Size());
     return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method);
@@ -600,33 +650,38 @@ int CWebServer::CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestH
 
     switch (responseDetails.type)
     {
-    case HTTPMemoryDownloadNoFreeNoCopy:
-      return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength, false, false, response);
+      case HTTPMemoryDownloadNoFreeNoCopy:
+        return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength,
+                                            false, false, response);
 
-    case HTTPMemoryDownloadNoFreeCopy:
-      return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength, false, true, response);
+      case HTTPMemoryDownloadNoFreeCopy:
+        return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength,
+                                            false, true, response);
 
-    case HTTPMemoryDownloadFreeNoCopy:
-      return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength, true, false, response);
+      case HTTPMemoryDownloadFreeNoCopy:
+        return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength,
+                                            true, false, response);
 
-    case HTTPMemoryDownloadFreeCopy:
-      return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength, true, true, response);
+      case HTTPMemoryDownloadFreeCopy:
+        return CreateMemoryDownloadResponse(request.connection, responseData, responseDataLength,
+                                            true, true, response);
 
-    default:
-      return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method);
+      default:
+        return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method);
     }
   }
 
   return CreateRangedMemoryDownloadResponse(handler, response);
 }
 
-int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const
+MHD_RESULT CWebServer::CreateRangedMemoryDownloadResponse(
+    const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response*& response) const
 {
   if (handler == nullptr)
     return MHD_NO;
 
-  const HTTPRequest &request = handler->GetRequest();
-  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
+  const HTTPRequest& request = handler->GetRequest();
+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
   HttpResponseRanges responseRanges = handler->GetResponseData();
 
   // if there's no or only one range this is not the right place
@@ -658,8 +713,10 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRe
   // adjust the HTTP status of the response
   handler->SetResponseStatus(MHD_HTTP_PARTIAL_CONTENT);
   // add Content-Range header
-  handler->AddResponseHeader(MHD_HTTP_HEADER_CONTENT_RANGE,
-    HttpRangeUtils::GenerateContentRangeHeaderValue(firstRangePosition, lastRangePosition, responseDetails.totalLength));
+  handler->AddResponseHeader(
+      MHD_HTTP_HEADER_CONTENT_RANGE,
+      HttpRangeUtils::GenerateContentRangeHeaderValue(firstRangePosition, lastRangePosition,
+                                                      responseDetails.totalLength));
 
   // generate a multipart boundary
   std::string multipartBoundary = HttpRangeUtils::GenerateMultipartBoundary();
@@ -670,7 +727,8 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRe
   handler->AddResponseHeader(MHD_HTTP_HEADER_CONTENT_TYPE, contentType);
 
   // generate the multipart boundary with the Content-Type header field
-  std::string multipartBoundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundary, contentType);
+  std::string multipartBoundaryWithHeader =
+      HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundary, contentType);
 
   std::string result;
   // add all the ranges to the result
@@ -680,14 +738,18 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRe
     if (range != ranges.begin())
       result += HEADER_NEWLINE;
 
-    // generate and append the multipart boundary with the full header (Content-Type and Content-Length)
-    result += HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundaryWithHeader, &*range);
+    // generate and append the multipart boundary with the full header (Content-Type and
+    // Content-Length)
+    result +=
+        HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundaryWithHeader, &*range);
 
     // and append the data of the range
-    result.append(static_cast<const char*>(range->GetData()), static_cast<size_t>(range->GetLength()));
+    result.append(static_cast<const char*>(range->GetData()),
+                  static_cast<size_t>(range->GetLength()));
 
     // check if we need to free the range data
-    if (responseDetails.type == HTTPMemoryDownloadFreeNoCopy || responseDetails.type == HTTPMemoryDownloadFreeCopy)
+    if (responseDetails.type == HTTPMemoryDownloadFreeNoCopy ||
+        responseDetails.type == HTTPMemoryDownloadFreeCopy)
       free(const_cast<void*>(range->GetData()));
   }
 
@@ -697,10 +759,13 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRe
   handler->AddResponseHeader(MHD_HTTP_HEADER_CONTENT_LENGTH, StringUtils::Format("%" PRIu64, static_cast<uint64_t>(result.size())));
 
   // finally create the response
-  return CreateMemoryDownloadResponse(request.connection, result.c_str(), result.size(), false, true, response);
+  return CreateMemoryDownloadResponse(request.connection, result.c_str(), result.size(), false,
+                                      true, response);
 }
 
-int CWebServer::CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const
+MHD_RESULT CWebServer::CreateRedirect(struct MHD_Connection* connection,
+                                      const std::string& strURL,
+                                      struct MHD_Response*& response) const
 {
   response = create_response(0, nullptr, MHD_NO, MHD_NO);
   if (response == nullptr)
@@ -713,13 +778,14 @@ int CWebServer::CreateRedirect(struct MHD_Connection *connection, const std::str
   return MHD_YES;
 }
 
-int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const
+MHD_RESULT CWebServer::CreateFileDownloadResponse(
+    const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response*& response) const
 {
   if (handler == nullptr)
     return MHD_NO;
 
-  const HTTPRequest &request = handler->GetRequest();
-  const HTTPResponseDetails &responseDetails = handler->GetResponseDetails();
+  const HTTPRequest& request = handler->GetRequest();
+  const HTTPResponseDetails& responseDetails = handler->GetResponseDetails();
   HttpResponseRanges responseRanges = handler->GetResponseData();
 
   std::shared_ptr<XFILE::CFile> file = std::make_shared<XFILE::CFile>();
@@ -761,7 +827,8 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
       if (!request.ranges.IsEmpty())
         context->ranges = request.ranges;
       else
-        HTTPRequestHandlerUtils::GetRequestedRanges(request.connection, fileLength, context->ranges);
+        HTTPRequestHandlerUtils::GetRequestedRanges(request.connection, fileLength,
+                                                    context->ranges);
     }
 
     uint64_t firstPosition = 0;
@@ -773,7 +840,8 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
     {
       handler->SetResponseStatus(MHD_HTTP_PARTIAL_CONTENT);
 
-      // we need to remember that we are ranged because the range length might change and won't be reliable anymore for length comparisons
+      // we need to remember that we are ranged because the range length might change and won't be
+      // reliable anymore for length comparisons
       ranged = true;
 
       context->ranges.GetFirstPosition(firstPosition);
@@ -785,7 +853,8 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
     // remember the total length
     totalLength = context->ranges.GetLength();
 
-    // adjust the MIME type and range length in case of multiple ranges which requires multipart boundaries
+    // adjust the MIME type and range length in case of multiple ranges which requires multipart
+    // boundaries
     if (context->rangeCountTotal > 1)
     {
       context->boundary = HttpRangeUtils::GenerateMultipartBoundary();
@@ -793,14 +862,19 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
 
       // build part of the boundary with the optional Content-Type header
       // "--<boundary>\r\nContent-Type: <content-type>\r\n
-      context->boundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundary, context->contentType);
+      context->boundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(
+          context->boundary, context->contentType);
       context->boundaryEnd = HttpRangeUtils::GenerateMultipartBoundaryEnd(context->boundary);
 
       // for every range, we need to add a boundary with header
-      for (HttpRanges::const_iterator range = context->ranges.Begin(); range != context->ranges.End(); ++range)
+      for (HttpRanges::const_iterator range = context->ranges.Begin();
+           range != context->ranges.End(); ++range)
       {
-        // we need to temporarily add the Content-Range header to the boundary to be able to determine the length
-        std::string completeBoundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, &*range);
+        // we need to temporarily add the Content-Range header to the boundary to be able to
+        // determine the length
+        std::string completeBoundaryWithHeader =
+            HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader,
+                                                                &*range);
         totalLength += completeBoundaryWithHeader.size();
 
         // add a newline before any new multipart boundary
@@ -815,10 +889,9 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
     context->ranges.GetFirstPosition(context->writePosition);
 
     // create the response object
-    response = MHD_create_response_from_callback(totalLength, 2048,
-                                                  &CWebServer::ContentReaderCallback,
-                                                  context.get(),
-                                                  &CWebServer::ContentReaderFreeCallback);
+    response =
+        MHD_create_response_from_callback(totalLength, 2048, &CWebServer::ContentReaderCallback,
+                                          context.get(), &CWebServer::ContentReaderFreeCallback);
     if (response == nullptr)
     {
       CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP response for %s to be filled from %s", m_port, request.pathUrl.c_str(), filePath.c_str());
@@ -829,7 +902,9 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
 
     // add Content-Range header
     if (ranged)
-      handler->AddResponseHeader(MHD_HTTP_HEADER_CONTENT_RANGE, HttpRangeUtils::GenerateContentRangeHeaderValue(firstPosition, lastPosition, fileLength));
+      handler->AddResponseHeader(
+          MHD_HTTP_HEADER_CONTENT_RANGE,
+          HttpRangeUtils::GenerateContentRangeHeaderValue(firstPosition, lastPosition, fileLength));
   }
   else
   {
@@ -850,10 +925,13 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHan
   return MHD_YES;
 }
 
-int CWebServer::CreateErrorResponse(struct MHD_Connection *connection, int responseType, HTTPMethod method, struct MHD_Response *&response) const
+MHD_RESULT CWebServer::CreateErrorResponse(struct MHD_Connection* connection,
+                                           int responseType,
+                                           HTTPMethod method,
+                                           struct MHD_Response*& response) const
 {
   size_t payloadSize = 0;
-  const void *payload = nullptr;
+  const void* payload = nullptr;
 
   if (method != HEAD)
   {
@@ -861,12 +939,12 @@ int CWebServer::CreateErrorResponse(struct MHD_Connection *connection, int respo
     {
       case MHD_HTTP_NOT_FOUND:
         payloadSize = strlen(PAGE_FILE_NOT_FOUND);
-        payload = (const void *)PAGE_FILE_NOT_FOUND;
+        payload = (const void*)PAGE_FILE_NOT_FOUND;
         break;
 
       case MHD_HTTP_NOT_IMPLEMENTED:
         payloadSize = strlen(NOT_SUPPORTED);
-        payload = (const void *)NOT_SUPPORTED;
+        payload = (const void*)NOT_SUPPORTED;
         break;
     }
   }
@@ -881,9 +959,15 @@ int CWebServer::CreateErrorResponse(struct MHD_Connection *connection, int respo
   return MHD_YES;
 }
 
-int CWebServer::CreateMemoryDownloadResponse(struct MHD_Connection *connection, const void *data, size_t size, bool free, bool copy, struct MHD_Response *&response) const
+MHD_RESULT CWebServer::CreateMemoryDownloadResponse(struct MHD_Connection* connection,
+                                                    const void* data,
+                                                    size_t size,
+                                                    bool free,
+                                                    bool copy,
+                                                    struct MHD_Response*& response) const
 {
-  response = create_response(size, const_cast<void*>(data), free ? MHD_YES : MHD_NO, copy ? MHD_YES : MHD_NO);
+  response = create_response(size, const_cast<void*>(data), free ? MHD_YES : MHD_NO,
+                             copy ? MHD_YES : MHD_NO);
   if (response == nullptr)
   {
     CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP download response", m_port);
@@ -893,29 +977,33 @@ int CWebServer::CreateMemoryDownloadResponse(struct MHD_Connection *connection,
   return MHD_YES;
 }
 
-int CWebServer::SendResponse(const HTTPRequest& request, int responseStatus, MHD_Response *response) const
+MHD_RESULT CWebServer::SendResponse(const HTTPRequest& request,
+                                    int responseStatus,
+                                    MHD_Response* response) const
 {
   LogResponse(request, responseStatus);
 
-  int ret = MHD_queue_response(request.connection, responseStatus, response);
+  MHD_RESULT ret = MHD_queue_response(request.connection, responseStatus, response);
   MHD_destroy_response(response);
 
   return ret;
 }
 
-int CWebServer::SendErrorResponse(const HTTPRequest& request, int errorType, HTTPMethod method) const
+MHD_RESULT CWebServer::SendErrorResponse(const HTTPRequest& request,
+                                         int errorType,
+                                         HTTPMethod method) const
 {
-  struct MHD_Response *response = nullptr;
-  int ret = CreateErrorResponse(request.connection, errorType, method, response);
+  struct MHD_Response* response = nullptr;
+  MHD_RESULT ret = CreateErrorResponse(request.connection, errorType, method, response);
   if (ret == MHD_NO)
     return MHD_NO;
 
   return SendResponse(request, errorType, response);
 }
 
-void* CWebServer::UriRequestLogger(void *cls, const char *uri)
+void* CWebServer::UriRequestLogger(void* cls, const char* uri)
 {
-  CWebServer *webServer = reinterpret_cast<CWebServer*>(cls);
+  CWebServer* webServer = reinterpret_cast<CWebServer*>(cls);
 
   // log the full URI
   if (webServer == nullptr)
@@ -935,9 +1023,9 @@ void CWebServer::LogRequest(const char* uri) const
   CLog::Log(LOGDEBUG, "CWebServer[%hu]: request received for %s", m_port, uri);
 }
 
-ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, size_t max)
+ssize_t CWebServer::ContentReaderCallback(void* cls, uint64_t pos, char* buf, size_t max)
 {
-  HttpFileDownloadContext *context = (HttpFileDownloadContext *)cls;
+  HttpFileDownloadContext* context = (HttpFileDownloadContext*)cls;
   if (context == nullptr || context->file == nullptr)
     return -1;
 
@@ -978,7 +1066,8 @@ ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, si
     }
 
     // put together the boundary for the current range
-    std::string boundary = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, &range);
+    std::string boundary =
+        HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, &range);
 
     // copy the boundary into the buffer
     memcpy(buf, boundary.c_str(), boundary.size());
@@ -999,7 +1088,8 @@ ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, si
   maximum = std::min(maximum, end - context->writePosition + 1);
 
   // seek to the position if necessary
-  if (context->file->GetPosition() < 0 || context->writePosition != static_cast<uint64_t>(context->file->GetPosition()))
+  if (context->file->GetPosition() < 0 ||
+      context->writePosition != static_cast<uint64_t>(context->file->GetPosition()))
     context->file->Seek(context->writePosition);
 
   // read data from the file
@@ -1026,16 +1116,19 @@ ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, si
   return written;
 }
 
-void CWebServer::ContentReaderFreeCallback(void *cls)
+void CWebServer::ContentReaderFreeCallback(void* cls)
 {
-  HttpFileDownloadContext *context = (HttpFileDownloadContext *)cls;
+  HttpFileDownloadContext* context = (HttpFileDownloadContext*)cls;
   delete context;
 
   CLog::Log(LOGDEBUG, LOGWEBSERVER, "CWebServer [OUT] done");
 }
 
 // local helper
-static void panicHandlerForMHD(void* unused, const char* file, unsigned int line, const char *reason)
+static void panicHandlerForMHD(void* unused,
+                               const char* file,
+                               unsigned int line,
+                               const char* reason)
 {
   CLog::Log(LOGSEVERE, "CWebServer: MHD serious error: reason \"%s\" in file \"%s\" at line %ui", reason ? reason : "",
             file ? file : "", line);
@@ -1063,7 +1156,7 @@ static void logFromMHD(void* unused, const char* fmt, va_list ap)
   }
 }
 
-bool CWebServer::LoadCert(std::string &skey, std::string &scert)
+bool CWebServer::LoadCert(std::string& skey, std::string& scert)
 {
   XFILE::CFile file;
   XFILE::auto_buffer buf;
@@ -1106,63 +1199,52 @@ struct MHD_Daemon* CWebServer::StartMHD(unsigned int flags, int port)
 
   MHD_set_panic_func(&panicHandlerForMHD, nullptr);
 
-  if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SERVICES_WEBSERVERSSL) &&
-      MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_YES &&
-      LoadCert(m_key, m_cert))
+  if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
+          CSettings::SETTING_SERVICES_WEBSERVERSSL) &&
+      MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_YES && LoadCert(m_key, m_cert))
     // SSL enabled
-    return MHD_start_daemon(flags |
-                          // one thread per connection
-                          // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
-                          // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
-                          MHD_USE_THREAD_PER_CONNECTION
+    return MHD_start_daemon(
+        flags |
+            // one thread per connection
+            // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
+            // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
+            MHD_USE_THREAD_PER_CONNECTION
 #if (MHD_VERSION >= 0x00095207)
-                          | MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */
+            |
+            MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with
+                                               MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */
 #endif
-                          | MHD_USE_DEBUG /* Print MHD error messages to log */
-                          | MHD_USE_SSL
-                          ,
-                          port,
-                          0,
-                          0,
-                          &CWebServer::AnswerToConnection,
-                          this,
-
-                          MHD_OPTION_CONNECTION_LIMIT, 512,
-                          MHD_OPTION_CONNECTION_TIMEOUT, timeout,
-                          MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this,
-                          MHD_OPTION_EXTERNAL_LOGGER, &logFromMHD, 0,
-                          MHD_OPTION_THREAD_STACK_SIZE, m_thread_stacksize,
-                          MHD_OPTION_HTTPS_MEM_KEY, m_key.c_str(),
-                          MHD_OPTION_HTTPS_MEM_CERT, m_cert.c_str(),
-                          MHD_OPTION_HTTPS_PRIORITIES, ciphers,
-                          MHD_OPTION_END);
+            | MHD_USE_DEBUG /* Print MHD error messages to log */
+            | MHD_USE_SSL,
+        port, 0, 0, &CWebServer::AnswerToConnection, this,
+
+        MHD_OPTION_CONNECTION_LIMIT, 512, MHD_OPTION_CONNECTION_TIMEOUT, timeout,
+        MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this,
+        MHD_OPTION_EXTERNAL_LOGGER, &logFromMHD, 0, MHD_OPTION_THREAD_STACK_SIZE,
+        m_thread_stacksize, MHD_OPTION_HTTPS_MEM_KEY, m_key.c_str(), MHD_OPTION_HTTPS_MEM_CERT,
+        m_cert.c_str(), MHD_OPTION_HTTPS_PRIORITIES, ciphers, MHD_OPTION_END);
 
   // No SSL
-  return MHD_start_daemon(flags |
-                          // one thread per connection
-                          // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
-                          // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
-                          MHD_USE_THREAD_PER_CONNECTION
+  return MHD_start_daemon(
+      flags |
+          // one thread per connection
+          // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
+          // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
+          MHD_USE_THREAD_PER_CONNECTION
 #if (MHD_VERSION >= 0x00095207)
-                          | MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */
+          | MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with
+                                               MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */
 #endif
-                          | MHD_USE_DEBUG /* Print MHD error messages to log */
-                          ,
-                          port,
-                          0,
-                          0,
-                          &CWebServer::AnswerToConnection,
-                          this,
-
-                          MHD_OPTION_CONNECTION_LIMIT, 512,
-                          MHD_OPTION_CONNECTION_TIMEOUT, timeout,
-                          MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this,
-                          MHD_OPTION_EXTERNAL_LOGGER, &logFromMHD, 0,
-                          MHD_OPTION_THREAD_STACK_SIZE, m_thread_stacksize,
-                          MHD_OPTION_END);
+          | MHD_USE_DEBUG /* Print MHD error messages to log */
+      ,
+      port, 0, 0, &CWebServer::AnswerToConnection, this,
+
+      MHD_OPTION_CONNECTION_LIMIT, 512, MHD_OPTION_CONNECTION_TIMEOUT, timeout,
+      MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this, MHD_OPTION_EXTERNAL_LOGGER,
+      &logFromMHD, 0, MHD_OPTION_THREAD_STACK_SIZE, m_thread_stacksize, MHD_OPTION_END);
 }
 
-bool CWebServer::Start(uint16_t port, const std::string &username, const std::string &password)
+bool CWebServer::Start(uint16_t port, const std::string& username, const std::string& password)
 {
   SetCredentials(username, password);
   if (!m_running)
@@ -1216,7 +1298,7 @@ bool CWebServer::WebServerSupportsSSL()
   return MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_YES;
 }
 
-void CWebServer::SetCredentials(const std::string &username, const std::string &password)
+void CWebServer::SetCredentials(const std::string& username, const std::string& password)
 {
   CSingleLock lock(m_critSection);
 
@@ -1225,7 +1307,7 @@ void CWebServer::SetCredentials(const std::string &username, const std::string &
   m_authenticationRequired = !m_authenticationPassword.empty();
 }
 
-void CWebServer::RegisterRequestHandler(IHTTPRequestHandler *handler)
+void CWebServer::RegisterRequestHandler(IHTTPRequestHandler* handler)
 {
   if (handler == nullptr)
     return;
@@ -1236,15 +1318,18 @@ void CWebServer::RegisterRequestHandler(IHTTPRequestHandler *handler)
 
   m_requestHandlers.push_back(handler);
   std::sort(m_requestHandlers.begin(), m_requestHandlers.end(),
-    [](IHTTPRequestHandler* lhs, IHTTPRequestHandler* rhs) { return rhs->GetPriority() < lhs->GetPriority(); });
+            [](IHTTPRequestHandler* lhs, IHTTPRequestHandler* rhs) {
+              return rhs->GetPriority() < lhs->GetPriority();
+            });
 }
 
-void CWebServer::UnregisterRequestHandler(IHTTPRequestHandler *handler)
+void CWebServer::UnregisterRequestHandler(IHTTPRequestHandler* handler)
 {
   if (handler == nullptr)
     return;
 
-  m_requestHandlers.erase(std::remove(m_requestHandlers.begin(), m_requestHandlers.end(), handler), m_requestHandlers.end());
+  m_requestHandlers.erase(std::remove(m_requestHandlers.begin(), m_requestHandlers.end(), handler),
+                          m_requestHandlers.end());
 }
 
 void CWebServer::LogRequest(const HTTPRequest& request) const
@@ -1253,9 +1338,11 @@ void CWebServer::LogRequest(const HTTPRequest& request) const
     return;
 
   std::multimap<std::string, std::string> headerValues;
-  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND, headerValues);
+  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND,
+                                                  headerValues);
   std::multimap<std::string, std::string> getValues;
-  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_GET_ARGUMENT_KIND, getValues);
+  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_GET_ARGUMENT_KIND,
+                                                  getValues);
 
   CLog::Log(LOGDEBUG, "CWebServer[%hu]  [IN] %s %s %s", m_port, request.version.c_str(), GetHTTPMethod(request.method).c_str(), request.pathUrlFull.c_str());
 
@@ -1278,7 +1365,8 @@ void CWebServer::LogResponse(const HTTPRequest& request, int responseStatus) con
     return;
 
   std::multimap<std::string, std::string> headerValues;
-  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND, headerValues);
+  HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND,
+                                                  headerValues);
 
   CLog::Log(LOGDEBUG, "CWebServer[%hu] [OUT] %s %d %s", m_port, request.version.c_str(), responseStatus, request.pathUrlFull.c_str());
 
@@ -1286,7 +1374,7 @@ void CWebServer::LogResponse(const HTTPRequest& request, int responseStatus) con
     CLog::Log(LOGDEBUG, "CWebServer[%hu] [OUT] %s: %s", m_port, header.first.c_str(), header.second.c_str());
 }
 
-std::string CWebServer::CreateMimeTypeFromExtension(const char *ext)
+std::string CWebServer::CreateMimeTypeFromExtension(const char* ext)
 {
   if (strcmp(ext, ".kar") == 0)
     return "audio/midi";
@@ -1296,10 +1384,12 @@ std::string CWebServer::CreateMimeTypeFromExtension(const char *ext)
   return CMime::GetMimeType(ext);
 }
 
-int CWebServer::AddHeader(struct MHD_Response *response, const std::string &name, const std::string &value) const
+MHD_RESULT CWebServer::AddHeader(struct MHD_Response* response,
+                                 const std::string& name,
+                                 const std::string& value) const
 {
   if (response == nullptr || name.empty())
-    return 0;
+    return MHD_NO;
 
   CLog::Log(LOGDEBUG, LOGWEBSERVER, "CWebServer[%hu] [OUT] %s: %s", m_port, name.c_str(), value.c_str());
 
diff --git a/xbmc/network/WebServer.h b/xbmc/network/WebServer.h
index c7a9093..1274a2e 100644
--- a/xbmc/network/WebServer.h
+++ b/xbmc/network/WebServer.h
@@ -56,17 +56,17 @@ protected:
 
   virtual void LogRequest(const char* uri) const;
 
-  virtual int HandlePartialRequest(struct MHD_Connection *connection, ConnectionHandler* connectionHandler, const HTTPRequest& request,
+  virtual MHD_RESULT HandlePartialRequest(struct MHD_Connection *connection, ConnectionHandler* connectionHandler, const HTTPRequest& request,
                                    const char *upload_data, size_t *upload_data_size, void **con_cls);
-  virtual int HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handler);
-  virtual int FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& handler, int responseStatus, struct MHD_Response *response);
+  virtual MHD_RESULT HandleRequest(const std::shared_ptr<IHTTPRequestHandler>& handler);
+  virtual MHD_RESULT FinalizeRequest(const std::shared_ptr<IHTTPRequestHandler>& handler, int responseStatus, struct MHD_Response *response);
 
 private:
   struct MHD_Daemon* StartMHD(unsigned int flags, int port);
 
   std::shared_ptr<IHTTPRequestHandler> FindRequestHandler(const HTTPRequest& request) const;
 
-  int AskForAuthentication(const HTTPRequest& request) const;
+  MHD_RESULT AskForAuthentication(const HTTPRequest& request) const;
   bool IsAuthenticated(const HTTPRequest& request) const;
 
   bool IsRequestCacheable(const HTTPRequest& request) const;
@@ -76,18 +76,18 @@ private:
   bool ProcessPostData(const HTTPRequest& request, ConnectionHandler *connectionHandler, const char *upload_data, size_t *upload_data_size, void **con_cls) const;
   void FinalizePostDataProcessing(ConnectionHandler *connectionHandler) const;
 
-  int CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
-  int CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
+  MHD_RESULT CreateMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
+  MHD_RESULT CreateRangedMemoryDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
 
-  int CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const;
-  int CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
-  int CreateErrorResponse(struct MHD_Connection *connection, int responseType, HTTPMethod method, struct MHD_Response *&response) const;
-  int CreateMemoryDownloadResponse(struct MHD_Connection *connection, const void *data, size_t size, bool free, bool copy, struct MHD_Response *&response) const;
+  MHD_RESULT CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const;
+  MHD_RESULT CreateFileDownloadResponse(const std::shared_ptr<IHTTPRequestHandler>& handler, struct MHD_Response *&response) const;
+  MHD_RESULT CreateErrorResponse(struct MHD_Connection *connection, int responseType, HTTPMethod method, struct MHD_Response *&response) const;
+  MHD_RESULT CreateMemoryDownloadResponse(struct MHD_Connection *connection, const void *data, size_t size, bool free, bool copy, struct MHD_Response *&response) const;
 
-  int SendResponse(const HTTPRequest& request, int responseStatus, MHD_Response *response) const;
-  int SendErrorResponse(const HTTPRequest& request, int errorType, HTTPMethod method) const;
+  MHD_RESULT SendResponse(const HTTPRequest& request, int responseStatus, MHD_Response *response) const;
+  MHD_RESULT SendErrorResponse(const HTTPRequest& request, int errorType, HTTPMethod method) const;
 
-  int AddHeader(struct MHD_Response *response, const std::string &name, const std::string &value) const;
+  MHD_RESULT AddHeader(struct MHD_Response *response, const std::string &name, const std::string &value) const;
 
   void LogRequest(const HTTPRequest& request) const;
   void LogResponse(const HTTPRequest& request, int responseStatus) const;
@@ -100,11 +100,11 @@ private:
   static ssize_t ContentReaderCallback (void *cls, uint64_t pos, char *buf, size_t max);
   static void ContentReaderFreeCallback(void *cls);
 
-  static int AnswerToConnection (void *cls, struct MHD_Connection *connection,
+  static MHD_RESULT AnswerToConnection (void *cls, struct MHD_Connection *connection,
                         const char *url, const char *method,
                         const char *version, const char *upload_data,
                         size_t *upload_data_size, void **con_cls);
-  static int HandlePostField(void *cls, enum MHD_ValueKind kind, const char *key,
+  static MHD_RESULT HandlePostField(void *cls, enum MHD_ValueKind kind, const char *key,
                              const char *filename, const char *content_type,
                              const char *transfer_encoding, const char *data, uint64_t off,
                              size_t size);
diff --git a/xbmc/network/httprequesthandler/HTTPFileHandler.cpp b/xbmc/network/httprequesthandler/HTTPFileHandler.cpp
index 2101d49..26e5390 100644
--- a/xbmc/network/httprequesthandler/HTTPFileHandler.cpp
+++ b/xbmc/network/httprequesthandler/HTTPFileHandler.cpp
@@ -23,7 +23,7 @@ CHTTPFileHandler::CHTTPFileHandler(const HTTPRequest &request)
     m_lastModified()
 { }
 
-int CHTTPFileHandler::HandleRequest()
+MHD_RESULT CHTTPFileHandler::HandleRequest()
 {
   return !m_url.empty() ? MHD_YES : MHD_NO;
 }
diff --git a/xbmc/network/httprequesthandler/HTTPFileHandler.h b/xbmc/network/httprequesthandler/HTTPFileHandler.h
index 3c74b52..6121315 100644
--- a/xbmc/network/httprequesthandler/HTTPFileHandler.h
+++ b/xbmc/network/httprequesthandler/HTTPFileHandler.h
@@ -19,7 +19,7 @@ class CHTTPFileHandler : public IHTTPRequestHandler
 public:
   ~CHTTPFileHandler() override = default;
 
-  int HandleRequest() override;
+  MHD_RESULT HandleRequest() override;
 
   bool CanHandleRanges() const override { return m_canHandleRanges; }
   bool CanBeCached() const override { return m_canBeCached; }
diff --git a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp
index de42e7f..6902be0 100644
--- a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp
+++ b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp
@@ -104,7 +104,7 @@ bool CHTTPImageTransformationHandler::CanHandleRequest(const HTTPRequest &reques
           options.find(TRANSFORMATION_OPTION_HEIGHT) != options.end());
 }
 
-int CHTTPImageTransformationHandler::HandleRequest()
+MHD_RESULT CHTTPImageTransformationHandler::HandleRequest()
 {
   if (m_response.type == HTTPError)
     return MHD_YES;
diff --git a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h
index c55015e..0d17afc 100644
--- a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h
+++ b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h
@@ -23,7 +23,7 @@ public:
   IHTTPRequestHandler* Create(const HTTPRequest &request) const override { return new CHTTPImageTransformationHandler(request); }
   bool CanHandleRequest(const HTTPRequest &request)const  override;
 
-  int HandleRequest() override;
+  MHD_RESULT HandleRequest() override;
 
   bool CanHandleRanges() const override { return true; }
   bool CanBeCached() const override { return true; }
diff --git a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp
index e8e2fa3..a4c3c19 100644
--- a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp
+++ b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp
@@ -25,7 +25,7 @@ bool CHTTPJsonRpcHandler::CanHandleRequest(const HTTPRequest &request) const
   return (request.pathUrl.compare("/jsonrpc") == 0);
 }
 
-int CHTTPJsonRpcHandler::HandleRequest()
+MHD_RESULT CHTTPJsonRpcHandler::HandleRequest()
 {
   CHTTPClient client(m_request.method);
   bool isRequest = false;
diff --git a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h
index 67c14b6..2659fd5 100644
--- a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h
+++ b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h
@@ -24,7 +24,7 @@ public:
   IHTTPRequestHandler* Create(const HTTPRequest &request) const override { return new CHTTPJsonRpcHandler(request); }
   bool CanHandleRequest(const HTTPRequest &request) const override;
 
-  int HandleRequest() override;
+  MHD_RESULT HandleRequest() override;
 
   HttpResponseRanges GetResponseData() const override;
 
diff --git a/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp b/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp
index 5f9aeef..a07ef0d 100644
--- a/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp
+++ b/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp
@@ -112,7 +112,7 @@ bool CHTTPPythonHandler::CanHandleRequest(const HTTPRequest &request) const
   return true;
 }
 
-int CHTTPPythonHandler::HandleRequest()
+MHD_RESULT CHTTPPythonHandler::HandleRequest()
 {
   if (m_response.type == HTTPError || m_response.type == HTTPRedirect)
     return MHD_YES;
diff --git a/xbmc/network/httprequesthandler/HTTPPythonHandler.h b/xbmc/network/httprequesthandler/HTTPPythonHandler.h
index 03c1506..166430e 100644
--- a/xbmc/network/httprequesthandler/HTTPPythonHandler.h
+++ b/xbmc/network/httprequesthandler/HTTPPythonHandler.h
@@ -25,7 +25,7 @@ public:
   bool CanBeCached() const override { return false; }
   bool GetLastModifiedDate(CDateTime &lastModified) const override;
 
-  int HandleRequest() override;
+  MHD_RESULT HandleRequest() override;
 
   HttpResponseRanges GetResponseData() const override { return m_responseRanges; }
 
diff --git a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp
index 80d1d67..f2ea1f2 100644
--- a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp
+++ b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp
@@ -61,7 +61,7 @@ bool HTTPRequestHandlerUtils::GetRequestedRanges(struct MHD_Connection *connecti
   return ranges.Parse(GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE), totalLength);
 }
 
-int HTTPRequestHandlerUtils::FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
+MHD_RESULT HTTPRequestHandlerUtils::FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
 {
   if (cls == nullptr || key == nullptr)
     return MHD_NO;
@@ -72,7 +72,7 @@ int HTTPRequestHandlerUtils::FillArgumentMap(void *cls, enum MHD_ValueKind kind,
   return MHD_YES;
 }
 
-int HTTPRequestHandlerUtils::FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
+MHD_RESULT HTTPRequestHandlerUtils::FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
 {
   if (cls == nullptr || key == nullptr)
     return MHD_NO;
diff --git a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h
index 9a07801..0ec5ed1 100644
--- a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h
+++ b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h
@@ -25,6 +25,6 @@ public:
 private:
   HTTPRequestHandlerUtils() = delete;
 
-  static int FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value);
-  static int FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value);
+  static MHD_RESULT FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value);
+  static MHD_RESULT FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value);
 };
diff --git a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp
index 01a6b50..0716a5d 100644
--- a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp
+++ b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp
@@ -18,7 +18,7 @@ bool CHTTPWebinterfaceAddonsHandler::CanHandleRequest(const HTTPRequest &request
   return (request.pathUrl.compare("/addons") == 0 || request.pathUrl.compare("/addons/") == 0);
 }
 
-int CHTTPWebinterfaceAddonsHandler::HandleRequest()
+MHD_RESULT CHTTPWebinterfaceAddonsHandler::HandleRequest()
 {
   m_responseData = ADDON_HEADER;
   ADDON::VECADDONS addons;
diff --git a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h
index e9b1c6d..23cea36 100644
--- a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h
+++ b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h
@@ -21,7 +21,7 @@ public:
   IHTTPRequestHandler* Create(const HTTPRequest &request) const override { return new CHTTPWebinterfaceAddonsHandler(request); }
   bool CanHandleRequest(const HTTPRequest &request) const override;
 
-  int HandleRequest() override;
+  MHD_RESULT HandleRequest() override;
 
   HttpResponseRanges GetResponseData() const override;
 
diff --git a/xbmc/network/httprequesthandler/IHTTPRequestHandler.h b/xbmc/network/httprequesthandler/IHTTPRequestHandler.h
index 4b1e40a..8f605ad 100644
--- a/xbmc/network/httprequesthandler/IHTTPRequestHandler.h
+++ b/xbmc/network/httprequesthandler/IHTTPRequestHandler.h
@@ -22,6 +22,12 @@
 
 #include "utils/HttpRangeUtils.h"
 
+#if MHD_VERSION >= 0x00097002
+#define MHD_RESULT enum MHD_Result
+#else
+#define MHD_RESULT int
+#endif
+
 class CDateTime;
 class CWebServer;
 
@@ -114,7 +120,7 @@ public:
    *
    * \return MHD_NO if a severe error has occurred otherwise MHD_YES.
    */
-  virtual int HandleRequest() = 0;
+  virtual MHD_RESULT HandleRequest() = 0;
 
   /*!
    * \brief Whether the HTTP response could also be provided in ranges.