def validate_etags(request, response, autotags=False):

    # Guard against being run twice.
    if hasattr(response, "ETag"):
        return

    status = response.status

    etag = response.headers.get('ETag')

    # Automatic ETag generation. See warning in docstring.
    if (not etag) and autotags:
        if status == 200:
            etag = response.collapse_body()
            etag = '"%s"' % hashlib.md5.new(etag).hexdigest()
            response.headers['ETag'] = etag

    response.ETag = etag

    # "If the request would, without the If-Match header field, result in
    # anything other than a 2xx or 412 status, then the If-Match header
    # MUST be ignored."
    if status >= 200 and status <= 299:
        conditions = request.headers.elements('If-Match') or []
        conditions = [str(x) for x in conditions]
        if conditions and not (conditions == ["*"] or etag in conditions):
            return httperror(
                request, response, 412,
                description="If-Match failed: ETag %r did not match %r" % (
                    etag, conditions
                )
            )

        conditions = request.headers.elements('If-None-Match') or []
        conditions = [str(x) for x in conditions]
        if conditions == ["*"] or etag in conditions:
            if request.method in ("GET", "HEAD"):
                return redirect(request, response, [], code=304)
            else:
                return httperror(
                    request, response, 412,
                    description=(
                        "If-None-Match failed: ETag %r matched %r" % (
                            etag, conditions
                        )
                    )
                )
Test the price vs. standard price for a variant.
dataset/ETHPy150Open circuits/circuits/circuits/web/tools.py/validate_etags--crossover with--dataset/ETHPy150Open diefenbach/django-lfs/lfs/gross_price/tests.py/GrossPriceTestCase.test_get_standard_price_2