ReynierPM
ReynierPM

Reputation: 18660

How to properly check whether header is sent along request or not

I have a application that make request to a Restful API and should send along a parameter called X-PDONE-SESSION-ID. I need to check whether that header is sent along request or does not so I've enabled and configured as follow:

/etc/httpd/conf/httpd.conf
LoadModule log_forensic_module modules/mod_log_forensic.so

I have enabled VirtualHost so this is the config file for that VH:

<VirtualHost *:80>
    ServerName admin.domain.local
    ServerAlias api.domain.local
    ServerAlias share.domain.local

    DocumentRoot /var/www/html/backend/web
    <Directory /var/www/html/backend/web>
        # enable the .htaccess rewrites
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>

    ErrorLog logs/pdone-error.log

    # CustomLog with format nickname
    LogFormat "%h %l %u %t %r %{x-pdone-session-id}i %{Referer}i %{User-Agent}i %>s %b" common
    CustomLog logs/pdone-access.log common
</VirtualHost>

Now, the following lines should do the work:

LogFormat "%h %l %u %t %r %{x-pdone-session-id}i %{Referer}i %{User-Agent}i %>s %b" common
CustomLog logs/pdone-access.log common

But this %{x-pdone-session-id}i is not logged on the log file, I have tried also by uppercase the value %{X-PDONE-SESSION-ID}i and didn't work neither. I got a log file like the one below:

192.168.3.1 - - [29/Jul/2015:10:22:19 -0430] "GET /app_dev.php/api/v1/reps/activity?_format=json&rid=00580000003AWtXAAW HTTP/1.1" 200 4369

I am making the request by using Postman Chrome extension and I am sending the header as image below shown, otherwise code fails with non authorized exception and code works, why I can't see that header on send headers? Why the value is not logged in? What I am missing here?

enter image description here

NOTE: if image is not shown good then right click over image and open in a new tab

Upvotes: 0

Views: 77

Answers (1)

Zimmi
Zimmi

Reputation: 1599

The nickname common is usually defined in the main server config. Just don't give the nick name common to an other log format, but any other name that is not defined in the main server, and that will be unique:

LogFormat "%h %l %u %t %r %{x-pdone-session-id}i %{Referer}i %{User-Agent}i %>s %b" pdone_common

I didn't know that before I've seen your question, but it is that nicknames defined in main server config cannot be overridden in VHost config.

Upvotes: 1

Related Questions