SlideShare a Scribd company logo
 

KBTW Lab #1
HTTP Basics
Eueung Mulyana
http://eueung.github.io/EL6240/http
EL-6240 | Attribution-ShareAlike CC BY-SA
1 / 24
Outline
Tools
Quick Start
Beyond CLI - Put Some Codes
2 / 24
 
Tools
3 / 24
4 / 24
This Checklist
Please:
Python 2
Putty or Terminal
Request Maker /
Postman (Chrome
Ext./App.)
Text Editor
cURL
 
Quick Start
5 / 24
SimpleHTTPServer
$>python-mSimpleHTTPServer8080
ServingHTTPon0.0.0.0port8080...
127.0.0.1--[02/Feb/201605:16:09]"GET/HTTP/1.1"200-
127.0.0.1--[02/Feb/201605:18:11]"GET/HTTP/1.1"200-
6 / 24
 
Request Maker - Response Header
7 / 24
 
Request Maker - Response Body -> Document
8 / 24
Put a Path
$>python-mSimpleHTTPServer8080
ServingHTTPon0.0.0.0port8080...
127.0.0.1--[02/Feb/201605:33:06]code404,messageFilenotfound
127.0.0.1--[02/Feb/201605:33:06]"GET/oncomHTTP/1.1"
A Different Port
 
9 / 24
$>python-mSimpleHTTPServer8080
ServingHTTPon0.0.0.0port8080...
127.0.0.1--[02/Feb/201605:40:41]code501,messageUnsupportedmethod('POST')
127.0.0.1--[02/Feb/201605:40:41]"POST/HTTP/1.1"501-
A Different Verb
10 / 24
Using PuTTY / Terminal
11 / 24
Server
PuTTY / Terminal
GET/HTTP/1.1
Host:localhost:8080
#orsimply
GET/HTTP/1.1
$>python-mSimpleHTTPServer8080
ServingHTTPon0.0.0.0port8080...
127.0.0.1--[03/Feb/201603:16:37]"GET/HTTP/1.1"200-
127.0.0.1--[03/Feb/201603:18:12]"GET/HTTP/1.1"200-
Response
HTTP/1.0200OK
Server:SimpleHTTP/0.6Python/2.7.10
Date:Tue,02Feb201620:16:37GMT
Content-type:text/html;charset=mbcs
Content-Length:246
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML3.2Final//EN"><html
<title>Directorylistingfor/</title>
<body>
<h2>Directorylistingfor/</h2><hr>
<ul>
<li><ahref="serv.py">serv.py</a>
<li><ahref="source/">source/</a>
</ul><hr>
</body></html>
12 / 24
Playing with Reqs
PuTTY / Terminal
GETHTTP/1.1
#
GET
$>python-mSimpleHTTPServer8080
ServingHTTPon0.0.0.0port8080...
127.0.0.1--[03/Feb/201603:21:19]code404,messageFilenotfound
127.0.0.1--[03/Feb/201603:21:19]"GETHTTP/1.1"404-
127.0.0.1--[03/Feb/201603:22:37]code400,messageBadrequestsyntax(
127.0.0.1--[03/Feb/201603:22:37]"GET"400-
Responses
<head><title>Errorresponse</title></head>
<body>
<h1>Errorresponse</h1>
<p>Errorcode404.
<p>Message:Filenotfound.
<p>Errorcodeexplanation:404=NothingmatchesthegivenURI
</body>
<head><title>Errorresponse</title></head>
<body>
<h1>Errorresponse</h1>
<p>Errorcode400.
<p>Message:Badrequestsyntax('GET').
<p>Errorcodeexplanation:400=Badrequestsyntaxorunsuppo
</body>
13 / 24
Playing with Reqs
PuTTY / Terminal
GET/oncomHTTP/1.1
$>python-mSimpleHTTPServer8080
ServingHTTPon0.0.0.0port8080...
127.0.0.1--[03/Feb/201603:18:51]code404,messageFilenotfound
127.0.0.1--[03/Feb/201603:18:51]"GET/oncomHTTP/1.1"
Response
HTTP/1.0404Filenotfound
Server:SimpleHTTP/0.6Python/2.7.10
Date:Tue,02Feb201620:18:51GMT
Content-Type:text/html
Connection:close
<head>
<title>Errorresponse</title>
</head>
<body>
<h1>Errorresponse</h1>
<p>Errorcode404.
<p>Message:Filenotfound.
<p>Errorcodeexplanation:404=NothingmatchesthegivenURI
</body>
14 / 24
Playing with Reqs
PuTTY / Terminal
POST/HTTP/1.1
$>python-mSimpleHTTPServer8080
ServingHTTPon0.0.0.0port8080...
127.0.0.1--[03/Feb/201603:26:23]code501,messageUnsupportedmethod(
127.0.0.1--[03/Feb/201603:26:23]"POST/HTTP/1.1"501-
Response
HTTP/1.0501Unsupportedmethod('POST')
Server:SimpleHTTP/0.6Python/2.7.10
Date:Tue,02Feb201620:26:23GMT
Content-Type:text/html
Connection:close
<head><title>Errorresponse</title></head>
<body>
<h1>Errorresponse</h1>
<p>Errorcode501.
<p>Message:Unsupportedmethod('POST').
<p>Errorcodeexplanation:501=Serverdoesnotsupportthis
</body>
15 / 24
 
Beyond CLI
Put Some Codes
16 / 24
Server #00
Codes
importSimpleHTTPServer
importSocketServer
#---------------------------------------------------
PORT =8000
Handler=SimpleHTTPServer.SimpleHTTPRequestHandler
httpd =SocketServer.TCPServer(("",PORT),Handler)
#---------------------------------------------------
print"Servingatport",PORT
httpd.serve_forever()
$>pythonserver-00.py
Servingatport8000
127.0.0.1--[04/Feb/201609:34:45]"GET/HTTP/1.1"200-
127.0.0.1--[04/Feb/201609:38:41]code501,messageUnsupportedmethod(
127.0.0.1--[04/Feb/201609:38:41]"POST/HTTP/1.1"501-
cURL
$>curl-vhttp://localhost:8000/
#...Connectedtolocalhost(127.0.0.1)port8000(#0)
>GET/HTTP/1.1
>Host:localhost:8000
>User-Agent:curl/7.47.0
>Accept:*/*
>
#HTTP1.0,assumecloseafterbody
<HTTP/1.0200OK
<Server:SimpleHTTP/0.6Python/2.7.10
<Date:Thu,04Feb201602:34:45GMT
<Content-type:text/html;charset=mbcs
<Content-Length:416
<
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML3.2Final//EN"><html>
<title>Directorylistingfor/</title>
<body>
<h2>Directorylistingfor/</h2>
<hr><ul>
<li><ahref="file.html">file.html</a>
<li><ahref="server-00.py">server-00.py</a>
<li><ahref="server-01.py">server-01.py</a>
<li><ahref="server-02.py">server-02.py</a>
<li><ahref="source/">source/</a>
</ul><hr>
</body></html>
#Closingconnection0
17 / 24
Server #00
$>pythonserver-00.py
Servingatport8000
127.0.0.1--[04/Feb/201609:34:45]"GET/HTTP/1.1"200-
127.0.0.1--[04/Feb/201609:38:41]code501,messageUnsupportedmethod(
127.0.0.1--[04/Feb/201609:38:41]"POST/HTTP/1.1"501-
cURL
$>curl-v-XPOSThttp://localhost:8000/
$>curl-v-d''http://localhost:8000/
#...Connectedtolocalhost(127.0.0.1)port8000(#0)
>POST/HTTP/1.1
>Host:localhost:8000
>User-Agent:curl/7.47.0
>Accept:*/*
>Content-Length:2
>Content-Type:application/x-www-form-urlencoded
>
#uploadcompletelysentoff:2outof2bytes
#HTTP1.0,assumecloseafterbody
<HTTP/1.0501Unsupportedmethod('POST')
<Server:SimpleHTTP/0.6Python/2.7.10
<Date:Thu,04Feb201602:38:41GMT
<Content-Type:text/html
<Connection:close
<
<head><title>Errorresponse</title></head>
<body>
<h1>Errorresponse</h1>
<p>Errorcode501.
<p>Message:Unsupportedmethod('POST').
<p>Errorcodeexplanation:501=Serverdoesnotsupportthis
</body>
#Closingconnection0
18 / 24
Server #01
Custom Handler
importSimpleHTTPServer
importSocketServer
#---------------------------------------------------
classGetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
defdo_GET(self):
printself.headers
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
#---------------------------------------------------
PORT =8000
Handler=GetHandler
httpd =SocketServer.TCPServer(("",PORT),Handler)
#---------------------------------------------------
print"servingatport",PORT
httpd.serve_forever()
$>pythonserver-01.py
servingatport8000
Host:localhost:8000
User-Agent:curl/7.47.0
Accept:*/*
127.0.0.1--[04/Feb/201611:50:12]"GET/HTTP/1.1"200-
$>curl-vhttp://localhost:8000/
#...Connectedtolocalhost(127.0.0.1)port8000(#0)
>GET/HTTP/1.1
>Host:localhost:8000
>User-Agent:curl/7.47.0
>Accept:*/*
>
#HTTP1.0,assumecloseafterbody
<HTTP/1.0200OK
<Server:SimpleHTTP/0.6Python/2.7.10
<Date:Thu,04Feb201604:50:12GMT
<Content-type:text/html;charset=mbcs
<Content-Length:416
<
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML3.2Final//EN"><html>
...Closingconnection0
19 / 24
Server #02
Fake POST
importSimpleHTTPServer
importSocketServer
#---------------------------------------------------
classGetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler)
defdo_GET(self):
printself.headers
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
defdo_POST(self):
printself.headers
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
#---------------------------------------------------
PORT =8000
Handler=GetHandler
httpd =SocketServer.TCPServer(("",PORT),Handler)
#---------------------------------------------------
print"servingatport",PORT
httpd.serve_forever()
20 / 24
Server #02
Fake POST
$>pythonserver-02.py
servingatport8000
Host:localhost:8000
User-Agent:curl/7.47.0
Accept:*/*
127.0.0.1--[04/Feb/201614:05:56]"POST/HTTP/1.1"200-
Host:localhost:8000
User-Agent:curl/7.47.0
Accept:*/*
Content-Length:2
Content-Type:application/x-www-form-urlencoded
127.0.0.1--[04/Feb/201614:07:22]"POST/HTTP/1.1"200-
$>curl-v-XPOSThttp://localhost:8000/
$>curl-v-XPOSThttp://localhost:8000/-d''
#...Connectedtolocalhost(127.0.0.1)port8000(#0)
>POST/HTTP/1.1
>Host:localhost:8000
>User-Agent:curl/7.47.0
>Accept:*/*
>Content-Length:2
>Content-Type:application/x-www-form-urlencoded
>
#uploadcompletelysentoff:2outof2bytes
#HTTP1.0,assumecloseafterbody
<HTTP/1.0200OK
<Server:SimpleHTTP/0.6Python/2.7.10
<Date:Thu,04Feb201607:07:22GMT
<Content-type:text/html;charset=mbcs
<Content-Length:416
<
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML3.2Final//EN"><html>
<title>Directorylistingfor/</title>
<body>
<h2>Directorylistingfor/</h2>
<hr>
<ul>
<li><ahref="file.html">file.html</a>
<li><ahref="serv.py">serv.py</a>
</ul><hr>
</body></html>
#Closingconnection0
21 / 24
 
Refs
22 / 24
Refs
1. SimpleHTTPServer - Simple HTTP request handler - Python documentation
2. BaseHTTPServer - Python Module of the Week
23 / 24
 

END
Eueung Mulyana
http://eueung.github.io/EL6240/http
EL-6240 | Attribution-ShareAlike CC BY-SA
24 / 24

More Related Content

PDF
Javascript tutorial RESTful APIs for Free
PDF
Ruby HTTP clients
PDF
Flask Basics
PDF
Flask RESTful Flask HTTPAuth
PDF
Ruby HTTP clients comparison
PDF
Flask Introduction - Python Meetup
PDF
Rest API using Flask & SqlAlchemy
PPT
How Danga::Socket handles asynchronous processing and how to write asynchrono...
Javascript tutorial RESTful APIs for Free
Ruby HTTP clients
Flask Basics
Flask RESTful Flask HTTPAuth
Ruby HTTP clients comparison
Flask Introduction - Python Meetup
Rest API using Flask & SqlAlchemy
How Danga::Socket handles asynchronous processing and how to write asynchrono...

What's hot (20)

PDF
Flask patterns
PPTX
Flask – Python
PDF
Monitoring with Syslog and EventMachine (RailswayConf 2012)
PDF
More than syntax
DOC
Integration of apache with tomcat
PDF
Common mistakes functional java snyk
PDF
Ten common mistakes made with Functional Java JBCNConf18
PDF
Ten common mistakes made in Function Java - iSense Java Summit
PDF
Flask With Server-Sent Event
PDF
Ten common mistakes made in Function Java
PPT
Assurer - a pluggable server testing/monitoring framework
PPT
Web
KEY
LvivPy - Flask in details
PPT
Learn flask in 90mins
PDF
Common mistakes functional java vjug
PDF
Common mistakes functional java | Oracle Code One 2018
PDF
Writing better functional java code - devnexus
PDF
Puppet Camp DC 2014: Managing Puppet with MCollective
PDF
Php logging
PPTX
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
Flask patterns
Flask – Python
Monitoring with Syslog and EventMachine (RailswayConf 2012)
More than syntax
Integration of apache with tomcat
Common mistakes functional java snyk
Ten common mistakes made with Functional Java JBCNConf18
Ten common mistakes made in Function Java - iSense Java Summit
Flask With Server-Sent Event
Ten common mistakes made in Function Java
Assurer - a pluggable server testing/monitoring framework
Web
LvivPy - Flask in details
Learn flask in 90mins
Common mistakes functional java vjug
Common mistakes functional java | Oracle Code One 2018
Writing better functional java code - devnexus
Puppet Camp DC 2014: Managing Puppet with MCollective
Php logging
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
Ad

Similar to Http basics (20)

PPTX
From ZERO to REST in an hour
PPTX
Performance #4 network
PPTX
Day02 a pi.
PPTX
Next Level Curl
PDF
Android Performance #4: Network
PDF
Clojure Workshop: Web development
PDF
Python tools for testing web services over HTTP
PDF
httpd — Apache Web Server
PDF
HTTP demystified for web developers
PDF
WebShell - confoo 2011 - sean coates
PPT
thisisahypertextbastamaonanasiyaprom.ppt
PPTX
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
PDF
ApacheCon 2014 - What's New in Apache httpd 2.4
PDF
Linux sever building
PDF
PDF
Demystifying REST - SFRails meetup
PDF
From zero to almost rails in about a million slides...
PPTX
HTTP Basic
PPT
Http
PDF
HTTP In-depth
From ZERO to REST in an hour
Performance #4 network
Day02 a pi.
Next Level Curl
Android Performance #4: Network
Clojure Workshop: Web development
Python tools for testing web services over HTTP
httpd — Apache Web Server
HTTP demystified for web developers
WebShell - confoo 2011 - sean coates
thisisahypertextbastamaonanasiyaprom.ppt
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
ApacheCon 2014 - What's New in Apache httpd 2.4
Linux sever building
Demystifying REST - SFRails meetup
From zero to almost rails in about a million slides...
HTTP Basic
Http
HTTP In-depth
Ad

More from Eueung Mulyana (20)

PDF
FGD Big Data
PDF
Hyper-Connectivity and Data Proliferation - Ecosystem Perspective
PDF
Industry 4.0 And Beyond The A.I* For Surviving A Tech-Accelerated World
PDF
Blockchain Introduction
PDF
Bringing Automation to the Classroom: A ChatOps-Based Approach
PDF
FinTech & Cryptocurrency Introduction
PDF
Open Source Networking Overview
PDF
ONOS SDN Controller - Clustering Tests & Experiments
PDF
Open stack pike-devstack-tutorial
PDF
Basic onos-tutorial
PDF
ONOS SDN Controller - Introduction
PDF
OpenDaylight SDN Controller - Introduction
PDF
Mininet Basics
PDF
Android Programming Basics
PDF
Cloud Computing: Overview and Examples
PDF
selected input/output - sensors and actuators
PDF
Connected Things, IoT and 5G
PDF
Connectivity for Local Sensors and Actuators Using nRF24L01+
PDF
NodeMCU with Blynk and Firebase
PDF
Trends and Enablers - Connected Services and Cloud Computing
FGD Big Data
Hyper-Connectivity and Data Proliferation - Ecosystem Perspective
Industry 4.0 And Beyond The A.I* For Surviving A Tech-Accelerated World
Blockchain Introduction
Bringing Automation to the Classroom: A ChatOps-Based Approach
FinTech & Cryptocurrency Introduction
Open Source Networking Overview
ONOS SDN Controller - Clustering Tests & Experiments
Open stack pike-devstack-tutorial
Basic onos-tutorial
ONOS SDN Controller - Introduction
OpenDaylight SDN Controller - Introduction
Mininet Basics
Android Programming Basics
Cloud Computing: Overview and Examples
selected input/output - sensors and actuators
Connected Things, IoT and 5G
Connectivity for Local Sensors and Actuators Using nRF24L01+
NodeMCU with Blynk and Firebase
Trends and Enablers - Connected Services and Cloud Computing

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
A Presentation on Touch Screen Technology
PDF
Enhancing emotion recognition model for a student engagement use case through...
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Mushroom cultivation and it's methods.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Zenith AI: Advanced Artificial Intelligence
MIND Revenue Release Quarter 2 2025 Press Release
1 - Historical Antecedents, Social Consideration.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
A Presentation on Touch Screen Technology
Enhancing emotion recognition model for a student engagement use case through...
1. Introduction to Computer Programming.pptx
Group 1 Presentation -Planning and Decision Making .pptx
Encapsulation_ Review paper, used for researhc scholars
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Heart disease approach using modified random forest and particle swarm optimi...
cloud_computing_Infrastucture_as_cloud_p
A comparative study of natural language inference in Swahili using monolingua...
Web App vs Mobile App What Should You Build First.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Mushroom cultivation and it's methods.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Hindi spoken digit analysis for native and non-native speakers
Zenith AI: Advanced Artificial Intelligence

Http basics