Monday, April 3, 2017

The Django server side shows http 400 and Invalid HTTP_HOST header message

I am using HTTPHandler to send logging messages to a Django Web server with The following code,     
import logging
import logging.handlers
logger = logging.getLogger('mylogger')
http_handler = logging.handlers.HTTPHandler('localhost:8000', '/VideoParser/lYYDownloaderClientLog')#, method='POST'
logger.addHandler(http_handler)
logger.error('testing remote logging')
but The server side shows http 400 and Invalid HTTP_HOST header message like this
Invalid HTTP_HOST header: 'localhost:8000,localhost'. The domain name provided i
s not valid according to RFC 1034/1035.
[03/Apr/2017 19:15:41] "GET /VideoParser/lYYDownloaderClientLog?filename=a.py&th
readName=MainThread&stack_info=None&processName=MainProcess&exc_text=None&create
d=1491218139.538086&levelname=ERROR&module=a&thread=3624&exc_info=None&relativeC
reated=112.00642585754395&levelno=40&pathname=C%3A%5CUsers%5Ci%5CDocuments%5CTen
cent+Files%5C2281570025%5CFileRecv%5Ca.py&msecs=538.0859375&msg=testing+remote+l
ogging&name=mylogger&args=%28%29&lineno=12&process=6700&funcName=%3Cmodule%3E HT
TP/1.1" 400 67823
so how to fix The issue ? related code django-test\LYYDownloaderServer\VideoParser\urls.py
from django.conf.urls import url
from . import views
app_name = 'VideoParser'
urlpatterns = [
url(r'lYYDownloaderClientLog.+',views.lYYDownloaderClientLog, name='lYYDownloaderClientLog')
]
django-test\LYYDownloaderServer\VideoParser\views.py
def lYYDownloaderClientLog(request):
print('----666666666666---', request.GET)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aa561085-f498-412e-9f2f-2e5af04df9a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment