Instructions to set up a basic LAMP+SSH server environment
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
2.2 KiB

  1. Author: Pekka Helenius (~Fincer), 2018
  2. This is an experimental patch, just introducing the principle of manipulating HTTP header response codes returned by Apache HTTP server to a client. The patch is mainly for personal use, nothing else. If you see it worth it, feel free to use it. And absolutely, feel free to modify it! If you see it just awful, ignore it. Thanks.
  3. The patch breaks HTTP standard by altering HTTP header response codes generated by Apache HTTP server. Generated codes are:
  4. If client request generates HTTP response code 401, the server returns error code 401.
  5. If client request generates HTTP response code 401->, the server returns error code 400.
  6. If client request generates HTTP response code 500->, the server returns error code 400 instead.
  7. Any other codes (100-308) will be returned normally, including 200 OK message.
  8. Remember to comment any unsupported ErrorDocument fields from your VirtualHost configurations before starting the server with this patch applied.
  9. All Apache HTTP response codes are listed in 'modules/http/http_protocol.c' file.
  10. This patch may break things badly, just be aware and proceed with care! Thanks.
  11. --- a/modules/http/http_protocol.c
  12. +++ b/modules/http/http_protocol.c
  13. @@ -1003,7 +1003,20 @@ AP_DECLARE(int) ap_index_of_response(int
  14. if (status < 100) {
  15. pos = (status + shortcut[i]);
  16. if (pos < shortcut[i + 1] && status_lines[pos] != NULL) {
  17. - return pos;
  18. + if (shortcut[i] == LEVEL_400) { /* If code class is 400 */
  19. + if (pos != (1 + shortcut[i])) { /* If code in 400 class is not 401, then */
  20. + return (0 + shortcut[i]); /* Return 400 */
  21. + }
  22. + else {
  23. + return pos; /* Else return 401 */
  24. + }
  25. + }
  26. + else if (shortcut[i] == LEVEL_500) { /* If code class is 500 */
  27. + return (0 + shortcut[i - 1]); /* Return first value of previous code class 400 */
  28. + }
  29. + else {
  30. + return pos; /* Return normal code */
  31. + }
  32. }
  33. else {
  34. return LEVEL_500; /* status unknown (falls in gap) */