473,749 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why do some HTTP headers show up in $_SERVER? Why not $_GET or $_POST ???


I noticed this odd PHP function in an article about AJAX and Prototype:

http://www.sitepoint.com/article/pai...pt-prototype/2

Prototype adds a custom HTTP header to all its AJAX requests so that your server
application can detect that it's an AJAX call, rather than a normal call. The header is:

X-Requested-With: XMLHttpRequest

Here's an example PHP function used to detect an AJAX call:

function isAjax() {
return isset($_SERVER['HTTP_X_REQUEST ED_WITH']) &&
$_SERVER ['HTTP_X_REQUEST ED_WITH'] == 'XMLHttpRequest ';
}

Most of the AJAX calls I've seen are GET or POST, so I expect them to
show up in the $_GET or $_POST arrays. Why would this header show up in
the $_SERVER array?

Apr 7 '06 #1
2 1775

lawrence k wrote:
Most of the AJAX calls I've seen are GET or POST, so I expect them to
show up in the $_GET or $_POST arrays. Why would this header show up in
the $_SERVER array?


A HTTP header is not an extra parameter passed via GET or POST. See
http://www.php.net/manual/en/function.header.php.

Apr 7 '06 #2
lawrence k:
Most of the AJAX calls I've seen are GET or POST, so I expect them to
show up in the $_GET or $_POST arrays. Why would this header show up in
the $_SERVER array?


GET and POST are just the names of two methods of sending an HTTP
request, not to be confused with the PHP variables of the same name.
The PHP variable $_GET makes available name=value pairs passed in the
query part of the request-URL (even if the actual method is POST), and
$_POST makes available name=value pairs passed in the body of the
request. $_SERVER, on the other hand, makes available some but not all
of the headers of the request.

http://www.php.net/manual/en/languag...predefined.php

HTH.

--
Jock

Apr 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3043
by: Lisa Pearlson | last post by:
Hi, I have a php script with no more than this: <?php echo "Hello World!"; ?> When a webbrowser client requests data, it receives Apache server headers, followed by my data: HTTP/1.1 200 OK
3
68776
by: Rick Edwards | last post by:
Can I do this? If I'm passing info in my HTTP headers, can I read this info via Javascript? I've seen some hope out there, but nothing definitive - I'm hoping to get that answer here.... TIA Rick
2
1772
by: Jane Withnolastname | last post by:
I have seen many posts here eschewing the use of META tags, advising instead to use http headers. I have no idea what they are or how to get to them, so I would appreciate some help. My specific problem is this: my server supports SSI, but does not display the index.shtml file, instead just displaying a directory listing. I have tried to have them change this, but tech support is an oxymoron (with emphasis on moron). In the meantime, I...
1
6592
by: Lakshmi Narayanan.R | last post by:
Hi Experts, In one SMS gateway project i need a great and urgent help from u all. There, the Service Providers sending the data thru "HTTP Headers" (For ex. sms-Id,sms-source ). So i need to get and parse the name value pairs, and need to respond/send the same way as coining the "HTTP Headers" (For ex. sms-Id,sms-destination,sms-msg ). Pls its urgent.
1
2144
by: John Smith | last post by:
I'm writing a service which accepts a POST call, updates a database and returns raw HTTP headers as specified below: HTTP/1.1 200 OK Content-type:text/plain Content-length:3 OK The code runs, and returns my headers, but only after its own:
6
4323
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx serves two purposes, 1. it contains a tab strip with response.redirects to navigate to the other pages; 2. I authenticate the user by check to see if a cookie exists, if it doesn't I redirect to a login screen.
8
24277
by: Andreas Klemt | last post by:
Hello, I get this error Message "cannot redirect after http headers have been sent" when I do this response.redirect ("home.aspx") How can I find out with vb.net if already a http header has been sent like If response.IsSentHttpHeader then ....
2
2604
by: sagar | last post by:
Hello Friends, I was working with Gdata to access the data in my google calander. I want to do this with a simple HTML-JS page, no server side scripting (hitherto dont know if this is practical). For this I need to read the HTTP headers for a GET response. Can anyone tell me if its possible to read the HTTP headers with Javascript or by some other method on client side.
10
3234
by: rup | last post by:
Hello, This is my first application on socket programming in vc++. I am facing problem that how to make connection to server, & make GET/POST request by HTTP. Please help me. Its urgent.... Thanks
0
8997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.