If you can't read please download the document
Upload
sulaeman-
View
79
Download
4
Embed Size (px)
Citation preview
HTTP
Garut Software Development Meetup
pemula
Sulaeman
Software Engineer @ BGC Digital Ltd
Part-time Freelancer
HTTP ?
Apa itu HTTP?
Kependekan dari HyperText Transfer Protocol
World Wide Web (WWW) dapat hidup karena ada HTTP
Digunakan oleh Web Browser untuk meminta dan menerima datadari Web Server
Web Browser?
Web Server?
Flow?
NetworkInternet
NetworkInternet
REQUEST
RESPONSE
Request
NetworkInternet
REQUEST
Request line
GET /index.php http/1.1
Header
Host: www.web-saya.com
Accept: text/html,application/xhtml+xml,image/webp,*/*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,id;q=0.6,ms;q=0.4
Body
...
Response
NetworkInternet
RESPONSE
Header
Date: Tue, 06 Sep 2016 00:13:57 GMT
Server: Apache
Status: 200 OK
Content-Type: text/html
Body
...
Browser
InspectNetwork
Request Examples
GET /index.php http/1.1
GET /buku-tamu.php?tanggal=2016-09-05 http/1.1
GET /gallery/kegiatan-agustusan.html http/1.1
GET /assets/images/foto-selfie.jpeg http/1.1
GET /assets/css/layout.css http/1.1
GET /assets/js/font.css http/1.1
GET /berita.php?page=2&tanggal=2016-09-05 http/1.1
GET /portofolio/web-applications?page=3 http/1.1
HTTP Request Verbs (methods)
GET /buku-tamu.php http/1.1
method
endpoint
HTTP version
POST /buku-tamu.php http/1.1
method
endpoint
HTTP version
DELETE /pegawai/21 http/1.1
method
endpoint
HTTP version
PATCH /pegawai/21/nama http/1.1
method
endpoint
HTTP version
PUT
OPTIONS
HEAD
CONNECT
Handling Request
Request
NetworkInternet
REQUEST
Request line
GET /index.php http/1.1
Header
Host: www.web-saya.com
Accept: text/html,application/xhtml+xml,image/webp,*/*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,id;q=0.6,ms;q=0.4
Body
...
HTTP GET method
GET /buku-tamu.php http/1.1
GET /berita.php?page=3&tanggal=2016-09-05 http/1.1
query parameters
Handling in PHP
HTTP POST method
POST /buku-tamu.php http/1.1
POST /berita.php?page=3&tanggal=2016-09-05 http/1.1
query parameters
Form
nama=Sulaeman&[email protected]&pesan=blabla blabla blablabla bla
Body
HTTP POST method handling in PHP
POST /buku-tamu.php http/1.1
POST /berita.php?page=3&tanggal=2016-09-05 http/1.1
query parameters
nama=Sulaeman&[email protected]&pesan=blabla blabla blablabla bla
Body
Handling in PHP
Predefined Variables in PHP
http://php.net/manual/en/reserved.variables.php
Server Response Status
Status Codes
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
200 OK
201 Created
204 No Content
301 Moved Permanently
304 Not Modified
307 Temporary Redirect
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
414 Request-URI Too Long
500 Internal Server Error
503 Service Unavailable
504 Gateway Timeout
Take It To The Next Level
What To Do Next?
AJAX (Asynchronous JavaScript And XML)
REST (REpresentational State Transfer)
Belajar Bahasa Inggris :: bisa pakai translate.google.com
Support Resources
HTTP - Hypertext Transfer Protocol
https://www.w3.org/Protocols/
PHP Docs
http://php.net/manual/en/reserved.variables.php
Terima Kasih
Pertanyaan?
@sulaeman
https://www.sulaeman.com
Kontak
https://id.linkedin.com/in/sulaeman
https://github.com/feelinc
Middleware menyediakan mekanisme yang mudah untuk menyaring request HTTP yang masuk ke aplikasi kita. Misalnya, middleware yang memverifikasi pengguna apakah sudah login atau belum. Jika pengguna belum login, dengan middleware bisa mengarahkan pengguna ke halaman login. Tentu saja, middleware dapat dibuat untuk melakukan berbagai proses selain otentikasi.
Sebuah middleware CORS (cross-origin resource sharing) bertanggung jawab untuk menambahkan HTTP header yang tepat untuk semua response.
Sebuah middleware logging mungkin untuk membuat log semua request yang masuk ke aplikasi Anda.