| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/django/middleware/__pycache__/ |
Upload File : |
�
�|�e! � � � d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl m
Z
d dlmZ d dl
mZ d d lmZ G d
� de� � Z G d� d
e� � ZdS )� N)�urlparse)�settings)�PermissionDenied)�
mail_managers)�HttpResponsePermanentRedirect)�
is_valid_path)�MiddlewareMixin)�escape_leading_slashesc �. � e Zd ZdZeZd� Zd� Zd� Zd� Z dS )�CommonMiddlewarea
"Common" middleware for taking care of some basic operations:
- Forbid access to User-Agents in settings.DISALLOWED_USER_AGENTS
- URL rewriting: Based on the APPEND_SLASH and PREPEND_WWW settings,
append missing slashes and/or prepends missing "www."s.
- If APPEND_SLASH is set and the initial URL doesn't end with a
slash, and it is not found in urlpatterns, form a new URL by
appending a slash at the end. If this new URL is found in
urlpatterns, return an HTTP redirect to this new URL; otherwise
process the initial URL as usual.
This behavior can be customized by subclassing CommonMiddleware and
overriding the response_redirect_class attribute.
c � � |j � d� � }|�3t j D ]&}|� |� � rt d� � ��'|� � � }t j o|o|� d� � }|r|j �d|��nd}| �
|� � r| � |� � }n|� � � }|s||� � � k r||z
}| �
|� � S dS )z�
Check for denied User-Agents and rewrite the URL based on
settings.APPEND_SLASH and settings.PREPEND_WWW
�HTTP_USER_AGENTNzForbidden user agentzwww.z://www.� )�META�getr �DISALLOWED_USER_AGENTS�searchr �get_host�PREPEND_WWW�
startswith�scheme�should_redirect_with_slash�get_full_path_with_slash�
get_full_path�response_redirect_class)�self�request�
user_agent�user_agent_regex�host�must_prepend�redirect_url�paths �:/usr/lib/python3/dist-packages/django/middleware/common.py�process_requestz CommonMiddleware.process_request"