SlideShare a Scribd company logo
1 of 27
Content Negotiation in HTTP
Presented by Ibnul Tahsin Bhuiyan
Resource vs Representation
Resource vs Representation
• Resource
• Representation
GET /data/miran
GET /data/miran.xml
GET /data/miran.json
Resource vs Representation
GET /data/miran.xml
<user>
<name>miran</name>
<address>dhaka</address>
</user>
Resource vs Representation
GET /data/miran.json
{
“name”:”miran”,
“address”:”dhaka”
}
Motivation of Content Negotiation
Motivation of Content Negotiation
{
"firstName":
"Chris",
"lastName":
"Morris"
}
{
“name": {
"first" : "Chris",
"last": "Morris"
}
}
{
“name": {
"full" : "Chris
Morris"
}
}
Principles Of Content Negotiation
https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation
Server Driven Content Negotiation
• Client requests for resource
• Client adds HTTP headers along with URL
• Accept
• Accept-Charset
• Accept-Encoding
• Accept-Language
• Server uses headers to choose a representation
• Server returns 406 Not Acceptable status code if it
can’t find the representation.
Server Driven Content Negotiation
https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation
Accept Header
The Accept request header field can be used to specify
media types which are acceptable for the response.
GET /data/miran
Accept: image/jpg
Accept Header
The Accept header can also have a quality factor, a
parameter indicating the relative degree of preference
between the different Media types.
GET /data/miran
Accept: image/jpg,
image/png; q=0.8,
image/*; q=0.5,
`application/json; q=0.1
Accept Header
List of some media types eligible for Accept header:
● Application
● Audio
● Font
● Image
● Text
● Video
Accept-Charset Header
The Accept-Charset header indicates to the server what
kinds of character encodings are understood by the
user-agent.
Accept-Charset: ISO-8859-1,utf-8;q=0.8,*;q=0.7
Accept-Encoding Header
The Accept-Encoding header defines the acceptable
content-encoding. The value is a q-factor list that
indicates the priority of the encoding values.
Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5
Accept-Language Header
The Accept-Language header is similar to Accept, but
restricts the set of natural languages that are preferred
as a response to the request.
GET /home
Accept-Language: no,
en-us;q=0.8,
en;q=0.7
Other Headers for Content
Negotiation
• The Accept-CH header
• The Accept-CH-Lifetime header
• The User-Agent header
• The Vary response header
Content-Type Negotiation
• The server introspects the Content-Type header
• Returns 415 Unsupported Media Type status code if
content type is not supported
POST /index HTTP/1.1
Accept: application/json
Content-Type: application/json
{
"foo": "bar"
}
RESTful Versioning Using Content Negotiation
Putting version in the URL couples the identity (the URL)
of the resource to its representation. That was never the
intent of REST. Instead, we should use Content
Negotiation to version representations.
RESTful Versioning Using Content Negotiation
{
“name": {
"first" : "Chris",
"last": "Morris"
}
}
{
“name": {
"full" : "Chris
Morris"
}
}
Version
1
Version
2
RESTful Versioning Using Content Negotiation
HTTP/1.1 200 OK
Content-Type:
application/vnd.linn.user+json;
version=1
{
“name": {
"first" : "Chris",
"last": "Morris"
}
}
GET /users/42 HTTP/1.1
Accept:
application/vnd.linn.user+json;
version=1
Request
Response
RESTful Versioning Using Content Negotiation
GET /users/42 HTTP/1.1
Accept:
application/vnd.linn.user+json;
version=2
Request
Response
HTTP/1.1 200 OK
Content-Type:
application/vnd.linn.user+json;
version=2
{
“name": {
"full" : "Chris Morris"
}
}
Agent Driven Negotiation
https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation
Content Negotiation Example
https://www.dotnettricks.com/learn/webapi/content-negotiation-in-asp-net-web-api
Disadvantage
• The server doesn't have total knowledge of
browser.
• Shared caches are less efficient.
• The information by the client is quite verbose.
Conclusion
If we want to build a true REST API, we should seriously
consider using Content Negotiation. In this way, we can
effectively decouple versioning from the identity of each
resource and have a clean URL pointing to only resource.
Thank You

More Related Content

What's hot

When apache pulsar meets apache flink
When apache pulsar meets apache flinkWhen apache pulsar meets apache flink
When apache pulsar meets apache flinkStreamNative
 
Kerberos, Token and Hadoop
Kerberos, Token and HadoopKerberos, Token and Hadoop
Kerberos, Token and HadoopKai Zheng
 
Elastic Data Processing with Apache Flink and Apache Pulsar
Elastic Data Processing with Apache Flink and Apache PulsarElastic Data Processing with Apache Flink and Apache Pulsar
Elastic Data Processing with Apache Flink and Apache PulsarStreamNative
 
Dynamic Authorization & Policy Control for Docker Environments
Dynamic Authorization & Policy Control for Docker EnvironmentsDynamic Authorization & Policy Control for Docker Environments
Dynamic Authorization & Policy Control for Docker EnvironmentsTorin Sandall
 
Measuring CDN performance and why you're doing it wrong
Measuring CDN performance and why you're doing it wrongMeasuring CDN performance and why you're doing it wrong
Measuring CDN performance and why you're doing it wrongFastly
 
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre ZembBuilding a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre ZembStreamNative
 
Hadoop and Kerberos: the Madness Beyond the Gate: January 2016 edition
Hadoop and Kerberos: the Madness Beyond the Gate: January 2016 editionHadoop and Kerberos: the Madness Beyond the Gate: January 2016 edition
Hadoop and Kerberos: the Madness Beyond the Gate: January 2016 editionSteve Loughran
 
Enhancing the default MongoDB Security
Enhancing the default MongoDB SecurityEnhancing the default MongoDB Security
Enhancing the default MongoDB SecurityIgor Donchovski
 
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...Kevin Minder
 
Practical Elasticsearch - real world use cases
Practical Elasticsearch - real world use casesPractical Elasticsearch - real world use cases
Practical Elasticsearch - real world use casesItamar
 
MongoDB HA - what can go wrong
MongoDB HA - what can go wrongMongoDB HA - what can go wrong
MongoDB HA - what can go wrongIgor Donchovski
 
Webinar: MongoDB Connector for Spark
Webinar: MongoDB Connector for SparkWebinar: MongoDB Connector for Spark
Webinar: MongoDB Connector for SparkMongoDB
 
Open Policy Agent (OPA) と Kubernetes Policy
Open Policy Agent (OPA) と Kubernetes PolicyOpen Policy Agent (OPA) と Kubernetes Policy
Open Policy Agent (OPA) と Kubernetes PolicyMotonori Shindo
 
Exploring the replication and sharding in MongoDB
Exploring the replication and sharding in MongoDBExploring the replication and sharding in MongoDB
Exploring the replication and sharding in MongoDBIgor Donchovski
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 

What's hot (20)

When apache pulsar meets apache flink
When apache pulsar meets apache flinkWhen apache pulsar meets apache flink
When apache pulsar meets apache flink
 
Copy of cgi
Copy of cgiCopy of cgi
Copy of cgi
 
Kerberos, Token and Hadoop
Kerberos, Token and HadoopKerberos, Token and Hadoop
Kerberos, Token and Hadoop
 
Elastic Data Processing with Apache Flink and Apache Pulsar
Elastic Data Processing with Apache Flink and Apache PulsarElastic Data Processing with Apache Flink and Apache Pulsar
Elastic Data Processing with Apache Flink and Apache Pulsar
 
Dynamic Authorization & Policy Control for Docker Environments
Dynamic Authorization & Policy Control for Docker EnvironmentsDynamic Authorization & Policy Control for Docker Environments
Dynamic Authorization & Policy Control for Docker Environments
 
Measuring CDN performance and why you're doing it wrong
Measuring CDN performance and why you're doing it wrongMeasuring CDN performance and why you're doing it wrong
Measuring CDN performance and why you're doing it wrong
 
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre ZembBuilding a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
 
Hadoop and Kerberos: the Madness Beyond the Gate: January 2016 edition
Hadoop and Kerberos: the Madness Beyond the Gate: January 2016 editionHadoop and Kerberos: the Madness Beyond the Gate: January 2016 edition
Hadoop and Kerberos: the Madness Beyond the Gate: January 2016 edition
 
Enhancing the default MongoDB Security
Enhancing the default MongoDB SecurityEnhancing the default MongoDB Security
Enhancing the default MongoDB Security
 
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
 
PPT
PPTPPT
PPT
 
MongoDB and Spark
MongoDB and SparkMongoDB and Spark
MongoDB and Spark
 
Practical Elasticsearch - real world use cases
Practical Elasticsearch - real world use casesPractical Elasticsearch - real world use cases
Practical Elasticsearch - real world use cases
 
How to scale MongoDB
How to scale MongoDBHow to scale MongoDB
How to scale MongoDB
 
MongoDB HA - what can go wrong
MongoDB HA - what can go wrongMongoDB HA - what can go wrong
MongoDB HA - what can go wrong
 
Webinar: MongoDB Connector for Spark
Webinar: MongoDB Connector for SparkWebinar: MongoDB Connector for Spark
Webinar: MongoDB Connector for Spark
 
Open Policy Agent (OPA) と Kubernetes Policy
Open Policy Agent (OPA) と Kubernetes PolicyOpen Policy Agent (OPA) と Kubernetes Policy
Open Policy Agent (OPA) と Kubernetes Policy
 
Gitminer 2.0 - Advance Search on Github
Gitminer 2.0 - Advance Search on GithubGitminer 2.0 - Advance Search on Github
Gitminer 2.0 - Advance Search on Github
 
Exploring the replication and sharding in MongoDB
Exploring the replication and sharding in MongoDBExploring the replication and sharding in MongoDB
Exploring the replication and sharding in MongoDB
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 

Similar to Content Negotiation in HTTP - Ibnul Tahsin Bhuiyan

Ws phpl1 php_apps_basics_1.2
Ws phpl1 php_apps_basics_1.2Ws phpl1 php_apps_basics_1.2
Ws phpl1 php_apps_basics_1.2Kensaku Suzuki
 
Build an API the right way
Build an API the right wayBuild an API the right way
Build an API the right waySoftware Guru
 
Building an Api the Right Way
Building an Api the Right WayBuilding an Api the Right Way
Building an Api the Right WayIcalia Labs
 
Beautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les HazlewoodBeautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les Hazlewoodjaxconf
 
Testing REST Web Services
Testing REST Web ServicesTesting REST Web Services
Testing REST Web ServicesJan Algermissen
 
PHP Training: Module 1
PHP Training: Module 1PHP Training: Module 1
PHP Training: Module 1hussulinux
 
Getting Started with Globus for Developers
Getting Started with Globus for DevelopersGetting Started with Globus for Developers
Getting Started with Globus for DevelopersGlobus
 
You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!Ben Ramsey
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web ServicesKasun Madusanke
 
Azure DocumentDB for Healthcare Integration - Part 2
Azure DocumentDB for Healthcare Integration - Part 2Azure DocumentDB for Healthcare Integration - Part 2
Azure DocumentDB for Healthcare Integration - Part 2BizTalk360
 
RESTful services
RESTful servicesRESTful services
RESTful servicesgouthamrv
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011Shreedhar Ganapathy
 
Single-Page Lab - ASNApalooza 2014
Single-Page Lab - ASNApalooza 2014Single-Page Lab - ASNApalooza 2014
Single-Page Lab - ASNApalooza 2014John Nickell
 
INFT132 093 03 Web Concepts
INFT132 093 03 Web ConceptsINFT132 093 03 Web Concepts
INFT132 093 03 Web ConceptsMichael Rees
 
Grokking the REST Architectural Style
Grokking the REST Architectural StyleGrokking the REST Architectural Style
Grokking the REST Architectural StyleBen Ramsey
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful FundamentalsSuresh Madhra
 

Similar to Content Negotiation in HTTP - Ibnul Tahsin Bhuiyan (20)

Ws phpl1 php_apps_basics_1.2
Ws phpl1 php_apps_basics_1.2Ws phpl1 php_apps_basics_1.2
Ws phpl1 php_apps_basics_1.2
 
Build an API the right way
Build an API the right wayBuild an API the right way
Build an API the right way
 
Building an Api the Right Way
Building an Api the Right WayBuilding an Api the Right Way
Building an Api the Right Way
 
HTTP
HTTPHTTP
HTTP
 
Web technologies: HTTP
Web technologies: HTTPWeb technologies: HTTP
Web technologies: HTTP
 
Beautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les HazlewoodBeautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les Hazlewood
 
Testing REST Web Services
Testing REST Web ServicesTesting REST Web Services
Testing REST Web Services
 
DNS & HTTP overview
DNS & HTTP overviewDNS & HTTP overview
DNS & HTTP overview
 
PHP Training: Module 1
PHP Training: Module 1PHP Training: Module 1
PHP Training: Module 1
 
Getting Started with Globus for Developers
Getting Started with Globus for DevelopersGetting Started with Globus for Developers
Getting Started with Globus for Developers
 
ROA.ppt
ROA.pptROA.ppt
ROA.ppt
 
You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web Services
 
Azure DocumentDB for Healthcare Integration - Part 2
Azure DocumentDB for Healthcare Integration - Part 2Azure DocumentDB for Healthcare Integration - Part 2
Azure DocumentDB for Healthcare Integration - Part 2
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 
Single-Page Lab - ASNApalooza 2014
Single-Page Lab - ASNApalooza 2014Single-Page Lab - ASNApalooza 2014
Single-Page Lab - ASNApalooza 2014
 
INFT132 093 03 Web Concepts
INFT132 093 03 Web ConceptsINFT132 093 03 Web Concepts
INFT132 093 03 Web Concepts
 
Grokking the REST Architectural Style
Grokking the REST Architectural StyleGrokking the REST Architectural Style
Grokking the REST Architectural Style
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 

More from Cefalo

Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCode Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCefalo
 
Overview of Cookies in HTTP - Miran al Mehrab
Overview of Cookies in HTTP - Miran al MehrabOverview of Cookies in HTTP - Miran al Mehrab
Overview of Cookies in HTTP - Miran al MehrabCefalo
 
Handshaking with HTTPS - Rafiul Islam
Handshaking with HTTPS - Rafiul IslamHandshaking with HTTPS - Rafiul Islam
Handshaking with HTTPS - Rafiul IslamCefalo
 
Evolution of HTTP - Miran Al Mehrab
Evolution of HTTP - Miran Al MehrabEvolution of HTTP - Miran Al Mehrab
Evolution of HTTP - Miran Al MehrabCefalo
 
Conditional Requests in HTTP - Nafis Fuad
Conditional Requests in HTTP - Nafis FuadConditional Requests in HTTP - Nafis Fuad
Conditional Requests in HTTP - Nafis FuadCefalo
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeyCefalo
 
Tips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
Tips to kick-start your Software Engineering Career - Ferdous Mahmud ShaonTips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
Tips to kick-start your Software Engineering Career - Ferdous Mahmud ShaonCefalo
 
Rest API Authentication - Uttom Akash
Rest API Authentication - Uttom AkashRest API Authentication - Uttom Akash
Rest API Authentication - Uttom AkashCefalo
 
Overview of REST - Raihan Ullah
Overview of REST - Raihan UllahOverview of REST - Raihan Ullah
Overview of REST - Raihan UllahCefalo
 
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonGetting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonCefalo
 
Brief of Caching - Rafiul Islam
Brief of Caching - Rafiul IslamBrief of Caching - Rafiul Islam
Brief of Caching - Rafiul IslamCefalo
 
Basics of HTTP - Nafis Fuad
Basics of HTTP - Nafis FuadBasics of HTTP - Nafis Fuad
Basics of HTTP - Nafis FuadCefalo
 
Cross Origin Resource Sharing (CORS) - Azizul Hakim
Cross Origin Resource Sharing (CORS) - Azizul HakimCross Origin Resource Sharing (CORS) - Azizul Hakim
Cross Origin Resource Sharing (CORS) - Azizul HakimCefalo
 

More from Cefalo (13)

Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCode Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
 
Overview of Cookies in HTTP - Miran al Mehrab
Overview of Cookies in HTTP - Miran al MehrabOverview of Cookies in HTTP - Miran al Mehrab
Overview of Cookies in HTTP - Miran al Mehrab
 
Handshaking with HTTPS - Rafiul Islam
Handshaking with HTTPS - Rafiul IslamHandshaking with HTTPS - Rafiul Islam
Handshaking with HTTPS - Rafiul Islam
 
Evolution of HTTP - Miran Al Mehrab
Evolution of HTTP - Miran Al MehrabEvolution of HTTP - Miran Al Mehrab
Evolution of HTTP - Miran Al Mehrab
 
Conditional Requests in HTTP - Nafis Fuad
Conditional Requests in HTTP - Nafis FuadConditional Requests in HTTP - Nafis Fuad
Conditional Requests in HTTP - Nafis Fuad
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit Dey
 
Tips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
Tips to kick-start your Software Engineering Career - Ferdous Mahmud ShaonTips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
Tips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
 
Rest API Authentication - Uttom Akash
Rest API Authentication - Uttom AkashRest API Authentication - Uttom Akash
Rest API Authentication - Uttom Akash
 
Overview of REST - Raihan Ullah
Overview of REST - Raihan UllahOverview of REST - Raihan Ullah
Overview of REST - Raihan Ullah
 
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonGetting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud Shaon
 
Brief of Caching - Rafiul Islam
Brief of Caching - Rafiul IslamBrief of Caching - Rafiul Islam
Brief of Caching - Rafiul Islam
 
Basics of HTTP - Nafis Fuad
Basics of HTTP - Nafis FuadBasics of HTTP - Nafis Fuad
Basics of HTTP - Nafis Fuad
 
Cross Origin Resource Sharing (CORS) - Azizul Hakim
Cross Origin Resource Sharing (CORS) - Azizul HakimCross Origin Resource Sharing (CORS) - Azizul Hakim
Cross Origin Resource Sharing (CORS) - Azizul Hakim
 

Recently uploaded

Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 

Recently uploaded (20)

Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 

Content Negotiation in HTTP - Ibnul Tahsin Bhuiyan

  • 1. Content Negotiation in HTTP Presented by Ibnul Tahsin Bhuiyan
  • 3. Resource vs Representation • Resource • Representation GET /data/miran GET /data/miran.xml GET /data/miran.json
  • 4. Resource vs Representation GET /data/miran.xml <user> <name>miran</name> <address>dhaka</address> </user>
  • 5. Resource vs Representation GET /data/miran.json { “name”:”miran”, “address”:”dhaka” }
  • 6. Motivation of Content Negotiation
  • 7. Motivation of Content Negotiation { "firstName": "Chris", "lastName": "Morris" } { “name": { "first" : "Chris", "last": "Morris" } } { “name": { "full" : "Chris Morris" } }
  • 8. Principles Of Content Negotiation https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation
  • 9. Server Driven Content Negotiation • Client requests for resource • Client adds HTTP headers along with URL • Accept • Accept-Charset • Accept-Encoding • Accept-Language • Server uses headers to choose a representation • Server returns 406 Not Acceptable status code if it can’t find the representation.
  • 10. Server Driven Content Negotiation https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation
  • 11. Accept Header The Accept request header field can be used to specify media types which are acceptable for the response. GET /data/miran Accept: image/jpg
  • 12. Accept Header The Accept header can also have a quality factor, a parameter indicating the relative degree of preference between the different Media types. GET /data/miran Accept: image/jpg, image/png; q=0.8, image/*; q=0.5, `application/json; q=0.1
  • 13. Accept Header List of some media types eligible for Accept header: ● Application ● Audio ● Font ● Image ● Text ● Video
  • 14. Accept-Charset Header The Accept-Charset header indicates to the server what kinds of character encodings are understood by the user-agent. Accept-Charset: ISO-8859-1,utf-8;q=0.8,*;q=0.7
  • 15. Accept-Encoding Header The Accept-Encoding header defines the acceptable content-encoding. The value is a q-factor list that indicates the priority of the encoding values. Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5
  • 16. Accept-Language Header The Accept-Language header is similar to Accept, but restricts the set of natural languages that are preferred as a response to the request. GET /home Accept-Language: no, en-us;q=0.8, en;q=0.7
  • 17. Other Headers for Content Negotiation • The Accept-CH header • The Accept-CH-Lifetime header • The User-Agent header • The Vary response header
  • 18. Content-Type Negotiation • The server introspects the Content-Type header • Returns 415 Unsupported Media Type status code if content type is not supported POST /index HTTP/1.1 Accept: application/json Content-Type: application/json { "foo": "bar" }
  • 19. RESTful Versioning Using Content Negotiation Putting version in the URL couples the identity (the URL) of the resource to its representation. That was never the intent of REST. Instead, we should use Content Negotiation to version representations.
  • 20. RESTful Versioning Using Content Negotiation { “name": { "first" : "Chris", "last": "Morris" } } { “name": { "full" : "Chris Morris" } } Version 1 Version 2
  • 21. RESTful Versioning Using Content Negotiation HTTP/1.1 200 OK Content-Type: application/vnd.linn.user+json; version=1 { “name": { "first" : "Chris", "last": "Morris" } } GET /users/42 HTTP/1.1 Accept: application/vnd.linn.user+json; version=1 Request Response
  • 22. RESTful Versioning Using Content Negotiation GET /users/42 HTTP/1.1 Accept: application/vnd.linn.user+json; version=2 Request Response HTTP/1.1 200 OK Content-Type: application/vnd.linn.user+json; version=2 { “name": { "full" : "Chris Morris" } }
  • 25. Disadvantage • The server doesn't have total knowledge of browser. • Shared caches are less efficient. • The information by the client is quite verbose.
  • 26. Conclusion If we want to build a true REST API, we should seriously consider using Content Negotiation. In this way, we can effectively decouple versioning from the identity of each resource and have a clean URL pointing to only resource.