Commit 68c600aa authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Add the ability to extend the methods that Apache understands

and have those methods <limit>able in the httpd.conf. It uses
the same bit mask/shifted offset as the original HTTP methods
such as M_GET or M_POST, but expands the total bits from an int to
an ap_int64_t to handle more bits for new request methods than
an int provides.
Submitted by:	Cody Sherr <csherr@covalent.net>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89869 13f79535-47bb-0310-9956-ffa450edef68
parent 6328b6ac
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
Changes with Apache 2.0.23-dev

  *) Add the ability to extend the methods that Apache understands
     and have those methods <limit>able in the httpd.conf. It uses 
     the same bit mask/shifted offset as the original HTTP methods 
     such as M_GET or M_POST, but expands the total bits from an int to 
     an ap_int64_t to handle more bits for new request methods than 
     an int provides.  [Cody Sherr <csherr@covalent.net>]

  *) Fix broken mod_mime behavior in merging its arguments.  Possible
     cause of unexplicable crashes introduced in 2.0.20.  [William Rowe]

+1 −1
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ struct cmd_parms_struct {
    /** Which allow-override bits are set */
    int override;
    /** Which methods are <Limit>ed */
    int limited;
    apr_int64_t limited;
    apr_array_header_t *limited_xmethods;
    ap_method_list_t *xlimited;

+1 −1
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ typedef struct require_line require_line;
/** A structure to keep track of authorization requirements */
struct require_line {
    /** Where the require line is in the config file. */
    int method_mask;
    apr_int64_t method_mask;
    /** The complete string from the command line */
    char *requirement;
};
+34 −0
Original line number Diff line number Diff line
@@ -227,6 +227,40 @@ AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
                             size_t length);
#endif

/* The index of the first bit field that is used to index into a limit
 * bitmask. M_INVALID + 1 to METHOD_NUMBER_LAST.
 */
#define METHOD_NUMBER_FIRST M_INVALID + 1

/* The max method number. Method numbers are used to shift bitmasks,
 * so this cannot exceed 63, and all bits high is equal to -1, which is a
 * special flag, so the last bit used has index 62.
 */
#define METHOD_NUMBER_LAST  62

/**
 * Register a new request method, and return the offset that will be
 * associated with that method.
 *
 * @param p        The pool to create registered method numbers from.
 * @param methname The name of the new method to register.
 * @return         Ab int value representing an offset into a bitmask.
 */
AP_DECLARE(int) ap_method_register(apr_pool_t *p, char *methname);

/**
 * Initialize the method_registry and allocate memory for it.
 *
 * @param p Pool to allocate memory for the registry from.
 */
AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p);

/*
 * This is a convenience macro to ease with checking a mask
 * against a method name.
 */
#define AP_METHOD_CHECK_ALLOWED(mask, methname) ((mask) & (1 << ap_method_number_of((methname))))

/**
 * Create a new method list with the specified number of preallocated
 * slots for extension methods.
+7 −4
Original line number Diff line number Diff line
@@ -498,7 +498,10 @@ AP_DECLARE(const char *) ap_get_server_built(void);
#define M_UNLOCK    14
#define M_INVALID   15

#define METHODS     16
/* METHODS needs to be equal to the number of bits
 * we are using for limit masks.
 */
#define METHODS     64

typedef struct ap_method_list_t ap_method_list_t;
/**
@@ -508,8 +511,8 @@ typedef struct ap_method_list_t ap_method_list_t;
 */
struct ap_method_list_t {
    /* The bitmask used for known methods */
    int method_mask;
    /* The array used for extension methods */
    apr_int64_t method_mask;
    /* the array used for extension methods */
    apr_array_header_t *method_list;
};

@@ -679,7 +682,7 @@ struct request_rec {
     *  HTTP_METHOD_NOT_ALLOWED.  Unfortunately this means that a Script GET
     *  handler can't be installed by mod_actions.
     */
    int allowed;
    apr_int64_t allowed;
    /** Array of extension methods */
    apr_array_header_t *allowed_xmethods; 
    /** List of allowed methods */
Loading