Thuta Learning
How the Web Works
IntermediateWeb Developmentbeginner

URL, HTTP နှင့် HTTPS

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • URL, HTTP နှင့် HTTPS concept ကို နားလည်ရှင်းပြနိုင်ရန်
  • Diagram ကို ဖတ်ပြီး request/data/event ဘယ်လိုစီးဆင်းသလဲ ခြေရာခံနိုင်ရန်
  • ဒီ piece က web architecture တစ်ခုလုံးထဲမှာ ဘယ်လို ဆက်စပ်နေသလဲ ရှင်းပြနိုင်ရန်

နားလည်ထားရမယ့် အချက်

web request တိုင်းသည် URL တစ်ခုနှင့် စတင်သည်။ ၎င်း၏ ဖွဲ့စည်းပုံကို တစ်ချက်ချင်း နားလည်ထားလျှင် web ကို အများကြီး ပိုမိုနားလည်လာနိုင်သည်။

https://api.example.com:443/users/42?active=true#profile ကို ဥပမာအဖြစ် ကြည့်ပါ - အပိုင်းတစ်ခုစီတွင် ကိုယ်ပိုင် တာဝန်ရှိသည်။

  • scheme (https) - မည်သည့် protocol ကို သုံးမည်ကို ဖော်ပြသည်
  • host (api.example.com) - မည်သည့် server ကို ဆက်သွယ်မည်ကို ဖော်ပြသည်
  • port (443) - server ပေါ်ရှိ မည်သည့် တံခါးကို ခေါက်မည်ကို ဖော်ပြသည်
  • path (/users/42) - မည်သည့် resource ကို တောင်းဆိုသည်ကို ဖော်ပြသည်
  • query (?active=true) - ထပ်ဆောင်း parameter များ
  • fragment (#profile) - browser ကသာ ကိုင်တွယ်ပြီး server ဆီ မရောက်ပါ

HTTP သည် browser နှင့် server ဆက်သွယ်ပုံကို သတ်မှတ်ပေးသည် - request တွင် method၊ URL၊ header များနှင့် တစ်ခါတစ်ရံ body ပါဝင်ပြီး response တွင် status၊ header များနှင့် များသောအားဖြင့် body ပါဝင်သည်။ method နှင့် status code အပြည့်အစုံကို API Tutorial တွင် လေ့လာနိုင်သည် - ဒီသင်ခန်းစာက ပုံစံကိုသာ လိုအပ်သည်။

HTTPS သည် HTTP အပေါ်တွင် TLS encryption ကို ထပ်ဆင့်ထည့်သည် - traffic ကို encrypt လုပ်ပြီး certificate များမှတစ်ဆင့် server identity ကို အတည်ပြုကာ ပို့ဆောင်နေစဉ် ချောက်ချမှုမှ ကာကွယ်ပေးသည်။

HTTPS သည် security အာမခံချက် မဟုတ်ပါ

HTTPS က connection ကို ကာကွယ်သည်၊ destination ကို မကာကွယ်ပါ။ phishing site တစ်ခုသည် padlock icon နှင့် တရားဝင် certificate ရှိသော်လည်း အန္တရာယ်ရှိနိုင်သည်။

URL
Uniform Resource Locator - web ပေါ်ရှိ resource တစ်ခုကို ရှာဖွေရန် သုံးသော လိပ်စာအပြည့်အစုံ ဖြစ်ပြီး scheme၊ host၊ optional port၊ path၊ query string နှင့် fragment တို့ဖြင့် ဖွဲ့စည်းထားသည်။
HTTPS
TLS encryption ဖြင့် ဖုံးအုပ်ထားသော HTTP ဖြစ်ပြီး encrypted connection၊ server identity verification နှင့် ပို့ဆောင်နေစဉ် ချောက်ချမှုမှ ကာကွယ်ပေးသည်။
text
ANATOMY OF A URL
----------------
ANATOMY OF A URL
-----------------

  https://api.example.com:443/users/42?active=true#profile

  scheme:    https              -> which protocol to use
  host:      api.example.com    -> which server to contact
  port:      443                -> which door on the server
  path:      /users/42          -> which resource is wanted
  query:     ?active=true       -> extra parameters
  fragment:  #profile           -> browser-only, never sent

REQUEST / RESPONSE FLOW
------------------------

  Browser  ---- HTTP Request ---->  Server
  Browser  <--- HTTP Response ----  Server

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

URL တစ်ခုကို ခွဲခြမ်းစိတ်ဖြာနိုင်ခြင်းက ပြဿနာအမှန်များကို မြန်ဆန်စွာ debug လုပ်ရာတွင် အထောက်အကူဖြစ်စေသည်။

  • server မှားလျှင် - host ကို စစ်ပါ
  • environment မှားလျှင် - port ကို စစ်ပါ
  • resource မှားလျှင် - path ကို စစ်ပါ
  • filtering/pagination ထူးဆန်းလျှင် - query string ကို စစ်ပါ
  • page အပိုင်းမှားသို့ ခုန်သွားလျှင် - fragment ကို စစ်ပါ

အောက်ပါ code သည် built-in URL class ကို သုံးထားသည် - library ထပ်ထည့်ရန် မလိုပါ။ URL ကို ပြောင်းပြီး ပြန် run ကြည့်ပါ။

padlock သည် လုံခြုံရေး စစ်ဆေးမှု အပြည့်အစုံ မဟုတ်ပါ

phishing site များသည် တရားဝင် HTTPS certificate ရှိနိုင်သည်။ HTTPS က connection ကိုသာ ကာကွယ်ပြီး server ယုံကြည်စိတ်ချရမှုကို မပြောပါ။

HTTPS သည် 100% လုံခြုံသည်ဟု မဆိုလိုပါ

HTTPS သည် connection ကို encrypt လုပ်ပေးရုံသာ ဖြစ်သည်။ site တစ်ခုသည် HTTPS ဖြင့် run နေသော်လည်း အားနည်းချက်၊ ပေါက်ကြားနေသော data (သို့) အန္တရာယ်ရှိသော code ရှိနိုင်သည်။

အတူတူ စမ်းရေးကြည့်မယ်

javascript
function parseUrl(urlString) {
  const url = new URL(urlString);
  return {
    scheme: url.protocol.replace(":", ""),
    host: url.hostname,
    port: url.port || (url.protocol === "https:" ? "443" : "80"),
    path: url.pathname,
    query: url.search,
    fragment: url.hash,
  };
}

console.log(parseUrl("https://api.example.com:443/users/42?active=true#profile"));
You should see
scheme: 'https'၊ host: 'api.example.com'၊ port: '443'၊ path: '/users/42'၊ query: '?active=true'၊ fragment: '#profile' ပါဝင်သော object ကို log ထုတ်သည်။

၅ မိနစ် စမ်းကြည့်

parseUrl function ကို အသုံးပြု၍ နေ့စဉ်သုံးနေသော site တစ်ခု၏ URL ကို parse လုပ်ပြီး search page မှ article တစ်ခုချင်းစီ page သို့ ပြောင်းလျှင် မည်သည့်အပိုင်း ပြောင်းလဲမည်ကို ဖော်ထုတ်ပါ။

သတိလေးတစ်ချက်

padlock icon (သို့) https:// ရှိလျှင် site တစ်ခုလုံး လုံးဝ ယုံကြည်စိတ်ချရသည်ဟု ယူဆခြင်း - connection encrypt ဖြစ်သည်ဟုသာ ဆိုလိုသည်။

ဒီသင်ခန်းစာကို mental model အဖြစ်ယူပြီး API Tutorial ကို depth အတွက်ယူမည့်အစား HTTP method/status code စာရင်းများကို ဒီနေရာမှာ အလွတ်ကျက်ရန် ကြိုးစားခြင်း။

Wikipedia - URLHow the Web Works

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • padlock icon (သို့) https:// ရှိလျှင် site တစ်ခုလုံး လုံးဝ ယုံကြည်စိတ်ချရသည်ဟု ယူဆခြင်း - connection encrypt ဖြစ်သည်ဟုသာ ဆိုလိုသည်။
  • ဒီသင်ခန်းစာကို mental model အဖြစ်ယူပြီး API Tutorial ကို depth အတွက်ယူမည့်အစား HTTP method/status code စာရင်းများကို ဒီနေရာမှာ အလွတ်ကျက်ရန် ကြိုးစားခြင်း။
  • ဒီ course က system map တစ်ခုပါ — REST/DNS/Database/Security ကို နက်နက်ရှိုင်းရှိုင်း လေ့လာချင်ရင် API Tutorial, Cloud & Deployment, SQL, Cybersecurity tutorial တွေဆီ ဆက်သွားပါ။

လေ့ကျင့်ခန်း

parseUrl function ကို အသုံးပြု၍ နေ့စဉ်သုံးနေသော site တစ်ခု၏ URL ကို parse လုပ်ပြီး search page မှ article တစ်ခုချင်းစီ page သို့ ပြောင်းလျှင် မည်သည့်အပိုင်း ပြောင်းလဲမည်ကို ဖော်ထုတ်ပါ။

You'll know it worked when: scheme: 'https'၊ host: 'api.example.com'၊ port: '443'၊ path: '/users/42'၊ query: '?active=true'၊ fragment: '#profile' ပါဝင်သော object ကို log ထုတ်သည်။