handling URL-rewritten PUT requests with PHP

Discussion in 'PHP' started by fritemayo, Jul 7, 2011.

  1. #1
    Hello all,

    This is a post I originally put up on the Apache forum, as it involves mod_rewrite, yet I think it would be a shame not to have PHP buffs come across it, as it may be reminiscent of situations they found themselves in in the past.

    We have an API hosted on Amazon's servers (hence no control over httpd.conf), and I use mod_rewrite to translate calls in (what I believe is) a customary way. The idea is:
    - to have several versions of the API in directories located in the root directory
    - to direct all API calls to a single entry point, aka handler.php

    Full details on the (very short) .htaccess file I use to rewrite URLs can be found in my original post (http://forums.digitalpoint.com/showthread.php?t=2224940)


    Problem: while everything works as expected with GET and POST requests, in the case of a PUT request handler.php is unable to retrieve the request data.

    If I issue a PUT request to, for instance my.api.host/v1/accounts/acc_id, then it is correctly rewritten into my.api.host/v1/handler.php?accounts/acc_id, but handler.php waits for incoming data on the php://input stream and eventually times out.

    I believe URL-rewriting has something to do with the problem, as a direct PUT request to my.api.host/v1/handler.php works fine, i.e. the script does read the request data as expected.

    Has anyone come across something similar ? Any tip would be greatly appreciated.
     
    fritemayo, Jul 7, 2011 IP
  2. fritemayo

    fritemayo Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The mistake was mine, purely mine, solely mine.
    Embarassed apologies to those who took the time to read my post.

    :)
     
    fritemayo, Jul 8, 2011 IP
  3. yusuyi

    yusuyi Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yusuyi, Jul 10, 2011 IP