عام HTTP ہیڈر

HTTP ہیڈر کلیدی-قدرت جوڑے ہوتے ہیں جو ہر درخواست اور جواب کے آغاز میں بھیجے جاتے ہیں۔ ان میں مواد کی قسم، کیش کے اصول اور تصدیق جیسا میٹا ڈیٹا ہوتا ہے۔ ویب ٹریفک بناتے یا ڈیبگ کرتے وقت سب سے عام ہیڈر پہچاننے کے لیے یہ شیٹ استعمال کریں۔

اپ ڈیٹ:

ہیڈرسمتمقصد
HostrequestIdentifies the server's host and port (from the URL).
User-AgentrequestReports the client software (browser, OS, bot) making the request.
AcceptrequestLists the response media types (MIME) the client can handle.
AuthorizationrequestCarries credentials (token, Basic auth) to authenticate the client.
Content-Typerequest/responseStates the media type of the request or response body.
Content-Lengthrequest/responseGives the size in bytes of the request or response body.
CookierequestSends stored key/value pairs from a previous response back to the server.
Set-CookieresponseServer instructs the client to store a cookie for later requests.
Cache-Controlrequest/responseDirects caching behaviour: no-cache, max-age, private, etc.
ETagresponseOpaque identifier for a resource version, used for revalidation.
If-None-MatchrequestSends an ETag; server returns 304 if the resource is unchanged.
LocationresponsePoints the client to a new URL for redirects (3xx) or created resources.
Access-Control-Allow-OriginresponsePermits a browser to share a response across origins (CORS).
X-Forwarded-ForrequestRecords the client IP as seen through a proxy or load balancer.
RefererrequestIndicates the URL of the page that linked to the requested resource.

نوٹس

اکثر پوچھے گئے سوالات

درخواست اور جواب ہیڈر میں کیا فرق ہے؟
درخواست ہیڈر کلائنٹ (براؤزر یا ایپ) کی جانب سے سرور کو بھیجے جاتے ہیں؛ جواب ہیڈر سرور اپنے جواب کے ساتھ واپس کرتا ہے۔ کچھ جیسے Content-Type دونوں طرف آتے ہیں۔
کیا HTTP ہیڈر کے نام کیس سے متاثر ہوتے ہیں؟
نہیں۔ ضابطے کے مطابق ہیڈر کے نام کیس سے متاثر نہیں ہوتے، اس لیے Content-Type اور content-type ایک ہی ہیں۔ Title-Case صرف ایک رواج ہے۔
Host ہیڈر کیا کرتا ہے؟
Host سرور کو بتاتا ہے کہ درخواست کس ڈومین کے لیے ہے۔ HTTP/1.1 میں یہ لازمی ہے اور ایک سرور کو نام سے کئی سائٹیں ہوسٹ کرنے دیتا ہے۔
ہیڈر کے ساتھ کیش کیسے کام کرتا ہے؟
Cache-Control طے کرتا ہے کہ جواب کتنی دیر کیش کیا جا سکتا ہے؛ ETag اور If-None-Match کلائنٹ کو پوچھنے دیتے ہیں 'کیا بدلا؟' اور ہلکا 304 Not Modified ملتا ہے۔