title: How to capture full HTTP request data (headers and body) with PHP?
body: <p>I have a problem implementing an API that works with Java, but fails to work with cURL. We've gone through everything so far and there must be something that is different between the requests that Java makes and what we make.</p>
  
  <p>In PHP we can get header data by looking at <code>$_SERVER['HTTP_*']</code> variables and we can get request body from <code>file_get_contents('php://input');</code> But we cannot get the exact data sent from user agent to client.</p>
  
  <p>Is it possible to get the full request, that user agent sends, with PHP? Headers and body included? If so, then how?</p>
  
  <p>The only example I found is <a href="http://www.daniweb.com/web-development/php/code/216846/get-http-request-headers-and-body" rel="noreferrer">here</a>, but this one gets the body the way I mentioned, while it gets headers by parsing through <code>$_SERVER</code>, which seems like a hack since it's never 100% of what was actually sent.</p>
  
  <p>All help and tips are appreciated!</p>