Kodax

تحليل HTTP Request — تحدي Python

اكتب الدالة parse_http_request(request_text) التي تحلل نص طلب HTTP وترجع قاموساً فيه method و path و version و headers (قاموس رؤوس الطلب).

def parse_http_request(request_text):
    """
    حلل HTTP request وأرجع قاموساً فيه:
    - method  (GET, POST, ...)
    - path    (/index.html)
    - version (HTTP/1.1)
    - headers (قاموس: اسم الرأس ← قيمته)
    """
    # اكتب كودك هنا
    pass

# تجربة
request = """GET /index.html HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0
"""

info = parse_http_request(request)
print(info)

حل هذا التحدي يرتبط بفتح دورة «أمن الشبكات» بحسابك.

ابدأ الحل