<commit_before># -*- coding:utf-8 -*-
from django.core.urlresolvers import reverse

import views
import utils

class YadisMiddleware:
  def process_request(self, request):
      if 'application/xrds+xml' in request.META.get('HTTP_ACCEPT', ''):
          return views.yadis(request)
  
  def process_response(self, request, response):
      if response.status_code >= 200 and response.status_code < 300:
          response['X-XRDS-Location'] = utils.absolute_url(reverse(views.yadis))
      return response<commit_msg>Выдача yadis-документа по application/xrds+xml только на identity url<commit_after># -*- coding:utf-8 -*-
from django.core.urlresolvers import reverse

import views
import utils

class YadisMiddleware:
  def process_request(self, request):
      if  utils.absolute_url(request.path) == utils.get_identity() and \
          'application/xrds+xml' in request.META.get('HTTP_ACCEPT', ''):
          return views.yadis(request)
  
  def process_response(self, request, response):
      if response.status_code >= 200 and response.status_code < 300:
          response['X-XRDS-Location'] = utils.absolute_url(reverse(views.yadis))
      return response
{'fraction_non_alphanumeric': 0.11426116838487972, 'fraction_numerical': 0.012027491408934709, 'mean_word_length': 3.8949579831932772, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4174104', 'n_tokens_mistral': 369, 'n_tokens_neox': 367, 'n_words': 79}