Implementing HTTP451 in Django during IETF 103 (with

Hello everyone, am going to share an amazing experience about my participation in IEFT Hackathon 103 with ( where I implemented HTTP 451 in Django.

For those who wish to know more about HTTP 451 Code and Django they may have more info on the following links

We implemented HTTP 451 for Django based on the following IETF RFC’s:

During the implementation we had some issues with the geolocation feature but with the robust core modules of Django the issues were quickly solved, and the POC (Proof of Concept) were running smooth.

We did use a proxy like to simulate connection from a proxy to cater for `HTTP_X_FORWARDED_FOR` header with is used when using proxy behind a webapp or server.

After all tests were done, we build the module named django-http-451 and published it on pypi

django-http-451 (0.1) — Http451 implementation for django

Below are the tests and POC for the django-http-451 module

A web resource that is accessible

Adding a resource to block on the django admin page

Adding the infos required to block the resource

By default is “Block by country” is not selected the resource is blocked for all. If you wish to block the resource for a specific country or countries you can do so by choosing “Block by country” and specifying the Country code (Alpha-2) line by line in the “Country code” Text field.

Testing a resource that is blocked (blocked for all countries) using the django-http-451 module:

Testing a blocked resource

The webpage displays the info you specified when registering the url you are blocking.

Testing a resource that is blocked (blocked for Mauritius only) using the django-http-451 module:

As you can see in the Headers of the response there is the Header “geo-scope-block” which include the country the resource is blocked for.

The source code of the module is at: