POST appears to be changed to GET when using iirf

Topics: Developer Forum
Dec 10, 2010 at 4:35 PM

Hello,

I posted this question in Issue Tracker but I'm not sure if this should be posted here also.

I'm using iirf with an simple iirf.ini in one virtual directory, it works fine for GETs, but when using with POST it works fine also but changes POST for GET. What am I doing wrong?.
When doing a POST the test url: http://amd64tst/InvoiceSampleSDEv2/

rest/customer/5
is being rewritted to http://amd64tst/InvoiceSampleSDEv2/customer_bc.svc/rest/5, which is correct, but also the method seems to be changed to GET, because the server application is receiving a GET.

If I try http://amd64tst/InvoiceSampleSDEv2/customer_bc.svc/rest/5, with POST, the server application receives a POST, so I think the problem is in the rewriting configuration.
I'm using WizTools.org RESTClient 2.3.2 to test POST methods.

Here it is the log file:

hu Dec 09 15:05:31 - 2088 - ReleaseOrExpireVdirConfig: vdir '/LM/W3SVC/1/Root/InvoiceSampleSDEv2' (era=0) (rc=0) (Expired=0) (ptr=0x029DCDF0)...
Thu Dec 09 15:07:25 - 1328 - Cached: DLL_THREAD_DETACH
Thu Dec 09 15:07:25 - 1328 - Cached: DLL_THREAD_DETACH
Thu Dec 09 15:07:25 - 1328 - Cached: DLL_THREAD_DETACH
Thu Dec 09 15:07:25 - 1328 - Cached: DLL_THREAD_DETACH
Thu Dec 09 15:07:25 - 1328 - Cached: DLL_THREAD_DETACH
Thu Dec 09 15:07:25 - 1328 - IsIniFileUpdated: C:\temp\InvoiceSampleSDEv2\web\Iirf.ini NO
Thu Dec 09 15:07:25 - 1328 - GetVdirConfig: Obtain vdir '/LM/W3SVC/1/Root/InvoiceSampleSDEv2' (era=0) (rc=1) (Expired=0) (ptr=0x029DCDF0)...
Thu Dec 09 15:07:25 - 1328 - HttpFilterProc: SF_NOTIFY_URL_MAP
Thu Dec 09 15:07:25 - 1328 - HttpFilterProc: cfg= 0x029DCDF0
Thu Dec 09 15:07:25 - 1328 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Thu Dec 09 15:07:25 - 1328 - DoRewrites
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: getting 'url'
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: 36 bytes ptr:0x0010B900
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: 'url' = '/InvoiceSampleSDEv2/rest/customer/5'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable_AutoFree: getting 'QUERY_STRING'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable_AutoFree: 1 bytes
Thu Dec 09 15:07:25 - 1328 - GetServerVariable_AutoFree: result ''
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: getting 'method'
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: 5 bytes ptr:0x00123C40
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: 'method' = 'POST'
Thu Dec 09 15:07:25 - 1328 - DoRewrites: New Url, before decoding: '/InvoiceSampleSDEv2/rest/customer/5'
Thu Dec 09 15:07:25 - 1328 - DoRewrites: Url (no decoding): '/InvoiceSampleSDEv2/rest/customer/5'
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: depth=0
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: getting 'SCRIPT_NAME'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: 36 bytes
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: result '/InvoiceSampleSDEv2/rest/customer/5'
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: no RewriteBase
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 1: pattern: ^(.*)/rest/customer(/.*)*$ subject: /InvoiceSampleSDEv2/rest/customer/5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 1: 3 match
Thu Dec 09 15:07:25 - 1328 - ReplaceServerVariables: alloc 27 bytes
Thu Dec 09 15:07:25 - 1328 - ReplaceServerVariables: in='$1/Customer_BC.svc/rest/$2' out='$1/Customer_BC.svc/rest/$2'
Thu Dec 09 15:07:25 - 1328 - GenerateReplacementString: alloc 51 bytes
Thu Dec 09 15:07:25 - 1328 - GenerateReplacementString: result '/InvoiceSampleSDEv2/Customer_BC.svc/rest//5'
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Result (length 43): /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: returning 1302
Thu Dec 09 15:07:25 - 1328 - DoRewrites: Redirect (code=302) Url to: '/InvoiceSampleSDEv2/Customer_BC.svc/rest//5'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: getting 'SERVER_NAME'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: 9 bytes
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: result 'amd64tst'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: getting 'SERVER_PORT'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: 3 bytes
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: result '80'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: getting 'HTTPS'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: 4 bytes
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: result 'off'
Thu Dec 09 15:07:25 - 1328 - HttpFilterProc: SF_NOTIFY_LOG
Thu Dec 09 15:07:25 - 1328 - ReleaseOrExpireVdirConfig: vdir '/LM/W3SVC/1/Root/InvoiceSampleSDEv2' (era=0) (rc=0) (Expired=0) (ptr=0x029DCDF0)...
Thu Dec 09 15:07:25 - 1328 - IsIniFileUpdated: C:\temp\InvoiceSampleSDEv2\web\Iirf.ini NO
Thu Dec 09 15:07:25 - 1328 - GetVdirConfig: Obtain vdir '/LM/W3SVC/1/Root/InvoiceSampleSDEv2' (era=0) (rc=1) (Expired=0) (ptr=0x029DCDF0)...
Thu Dec 09 15:07:25 - 1328 - HttpFilterProc: SF_NOTIFY_URL_MAP
Thu Dec 09 15:07:25 - 1328 - HttpFilterProc: cfg= 0x029DCDF0
Thu Dec 09 15:07:25 - 1328 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Thu Dec 09 15:07:25 - 1328 - DoRewrites
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: getting 'url'
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: 44 bytes ptr:0x0010B900
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: 'url' = '/InvoiceSampleSDEv2/Customer_BC.svc/rest//5'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable_AutoFree: getting 'QUERY_STRING'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable_AutoFree: 1 bytes
Thu Dec 09 15:07:25 - 1328 - GetServerVariable_AutoFree: result ''
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: getting 'method'
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: 4 bytes ptr:0x00123C40
Thu Dec 09 15:07:25 - 1328 - GetHeader_AutoFree: 'method' = 'GET'
Thu Dec 09 15:07:25 - 1328 - DoRewrites: New Url, before decoding: '/InvoiceSampleSDEv2/Customer_BC.svc/rest//5'
Thu Dec 09 15:07:25 - 1328 - DoRewrites: Url (no decoding): '/InvoiceSampleSDEv2/Customer_BC.svc/rest//5'
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: depth=0
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: getting 'SCRIPT_NAME'
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: 36 bytes
Thu Dec 09 15:07:25 - 1328 - GetServerVariable: result '/InvoiceSampleSDEv2/Customer_BC.svc'
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: no RewriteBase
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 1: pattern: ^(.*)/rest/customer(/.*)*$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 1: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 2: pattern: ^(.*)/rest/invoice(/.*)*$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 2: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 3: pattern: ^(.*)/rest/item(/.*)*$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 3: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 4: pattern: ^(.*)/rest/transaction1(/.*)*$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 4: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 5: pattern: ^(.*)/rest/transactionauto(/.*)*$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 5: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 6: pattern: ^(.*)/rest/trnfk(/.*)*$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 6: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 7: pattern: ^(.*)/rest/hello(/.*)*$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 7: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 8: pattern: ^(.*)/rest/dataprovider1(/.*)*$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 8: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 9: pattern: ^(.*)/rest/dataprovider2(/.*)*$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 9: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 10: pattern: ^(.*)/rest/metadata/(.*).json$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 10: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 11: pattern: ^(.*)/rest/metadata$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 11: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 12: pattern: ^(.*)/rest/metadata/images/(.*)$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 12: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 13: pattern: ^(.*)/rest/metadata/(.*)$ subject: /InvoiceSampleSDEv2/Customer_BC.svc/rest//5
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: Rule 13: -1 (No match)
Thu Dec 09 15:07:25 - 1328 - EvaluateRules: returning 0
Thu Dec 09 15:07:25 - 1328 - DoRewrites: No Rewrite
Thu Dec 09 15:07:25 - 1328 - HttpFilterProc: SF_NOTIFY_URL_MAP
Thu Dec 09 15:07:25 - 1328 - HttpFilterProc: cfg= 0x029DCDF0
Thu Dec 09 15:07:25 - 2616 - HttpFilterProc: SF_NOTIFY_URL_MAP
Thu Dec 09 15:07:25 - 2616 - HttpFilterProc: cfg= 0x029DCDF0
Thu Dec 09 15:07:26 - 2616 - HttpFilterProc: SF_NOTIFY_LOG
Thu Dec 09 15:07:26 - 2616 - ReleaseOrExpireVdirConfig: vdir '/LM/W3SVC/1/Root/InvoiceSampleSDEv2' (era=0) (rc=0) (Expired=0) (ptr=0x029DCDF0)...


This is the iirf.ini:

RewriteEngine ON
StatusInquiry ON

RewriteLogLevel 5
RewriteLog c:\temp\iirf.log

RedirectRule ^(.*)/rest/customer(/.*)*$ $1/Customer_BC.svc/rest/$2 [I]
RedirectRule ^(.*)/rest/invoice(/.*)*$ $1/Invoice_BC.svc/rest/$2
RedirectRule ^(.*)/rest/item(/.*)*$ $1/Item_BC.svc/rest/$2
RedirectRule ^(.*)/rest/transaction1(/.*)*$ $1/Transaction1_BC.svc/rest/$2
RedirectRule ^(.*)/rest/transactionauto(/.*)*$ $1/TransactionAuto_BC.svc/rest/$2
RedirectRule ^(.*)/rest/trnfk(/.*)*$ $1/TrnFk_BC.svc/rest/$2
RedirectRule ^(.*)/rest/hello(/.*)*$ $1/ahello.svc/rest/$2
RedirectRule ^(.*)/rest/dataprovider1(/.*)*$ $1/DataProvider1.svc/rest/$2
RedirectRule ^(.*)/rest/dataprovider2(/.*)*$ $1/DataProvider2.svc/rest/$2
RedirectRule ^(.*)/rest/metadata/(.*).json$ $1/gxmetadata/{R:1}.json [I,L]
RedirectRule ^(.*)/rest/metadata$ $1/gxmetadata/gx_entity_list.json [I,L]
RedirectRule ^(.*)/rest/metadata/images/(.*)$ $1/gxmetadata/images/$2 [I,L]
RedirectRule ^(.*)/rest/metadata/(.*)$ $1/gxmetadata/$2.json [I,L]


I don't have a global one.

Thanks.
Claudia.
Dec 10, 2010 at 6:06 PM

I figured one problem with my .ini file. I used RedirectRule instruction instead of RewriteRule. I changed the .ini file to:

RewriteEngine ON
StatusInquiry ON
RewriteRule ^(.*)/rest/customer(/.*)*$ $1/Customer_BC.svc/rest$2 [I,L]
RewriteRule ^(.*)/rest/invoice(/.*)*$ $1/Invoice_BC.svc/rest$2 [I,L]
RewriteRule ^(.*)/rest/item(/.*)*$ $1/Item_BC.svc/rest$2 [I,L]
RewriteRule ^(.*)/rest/transaction1(/.*)*$ $1/Transaction1_BC.svc/rest$2 [I,L]
RewriteRule ^(.*)/rest/transactionauto(/.*)*$ $1/TransactionAuto_BC.svc/rest$2 [I,L]
RewriteRule ^(.*)/rest/trnfk(/.*)*$ $1/TrnFk_BC.svc/rest$2 [I,L]
RewriteRule ^(.*)/rest/hello(/.*)*$ $1/ahello.svc/rest$2 [I,L]
RewriteRule ^(.*)/rest/dataprovider1(/.*)*$ $1/DataProvider1.svc/rest$2 [I,L]
RewriteRule ^(.*)/rest/dataprovider2(/.*)*$ $1/DataProvider2.svc/rest$2 [I,L]
RewriteRule ^(.*)/rest/metadata/(.*).json$ $1/gxmetadata/{R:1}.json [I,L]
RewriteRule ^(.*)/rest/metadata$ $1/gxmetadata/gx_entity_list.json [I,L]
RewriteRule ^(.*)/rest/metadata/images/(.*)$ $1/gxmetadata/images/$2 [I,L]
RewriteRule ^(.*)/rest/metadata/(.*)$ $1/gxmetadata/$2.json [I,L]

 

but I still get a redirect, I see the rewritten url in the browser. It's sending a response code of 307 to the browser. I already restarted IIS. I'm testing it on windows 2003 server (IIS6). Any help would be appreciated.

Claudia.

Coordinator
Dec 14, 2010 at 12:39 PM

There's no redirect rule in your ini file.  I'm not sure where the 307 is originating.

To find out, I suggest you employ an http debugging proxy, like Fiddler2, on the browser machine. This will show you the HTTP requests and responses that are sent and received by the browser.  If there's a 307, you'll see it there.

Also examine the IIRF and IIS logs on the server.  The IIRF log should show some log statements for each request handled by IIS.  You can interpret that to see what IIRF decided to do with the request.  Also check the IIS log to see the eventual response from IIS.  For example, if the page that eventually handles the request returns a redirect/307, IIS will show a redirect/307 in the log.  

 

Coordinator
Dec 14, 2010 at 12:44 PM

See also this forum post, which talks about some issues with HTTP 307s.

Coordinator
Dec 14, 2010 at 12:46 PM

Also -the issue tracker is for tracking bugs in IIRF.The discussion forum (this forum) is for discussing questions and problems.

The information you've provided isn't enough to declare that the behavior you're seeing is a result of a bug in IIRF. So I'm going to close that issue.

Dec 14, 2010 at 12:51 PM

You are right, I should have put a rewrite rule instead of redirect rule. That's the problem. It was my mistake, sorry. Thank you very much.

 

Coordinator
Dec 14, 2010 at 12:54 PM

Claudia, you said that earlier, and you also said you were still having the problem.

I guess that's no longer the case?

Dec 14, 2010 at 1:05 PM

I changed redirectrule for rewriterule, and that works for the static rewrite rules. The ones like:

RewriteRule ^(.*)/rest/metadata/(.*).json$ $1/gxmetadata/{R:1}.json [I,L]
RewriteRule ^(.*)/rest/metadata$ $1/gxmetadata/gx_entity_list.json [I,L]

but I still have the problem with rules like this: RewriteRule ^(.*)/rest/customer(/.*)*$ $1/Customer_BC.svc/rest$2 [I,L]

I think it is because something related to the regular expression, I changed the previous one for this one:

RewriteRule ^(.*)/rest/customer(/[^/]*)*$ $1/Customer_BC.svc/rest/$2 [I,L]

and it worked.  I don't have the POST changed for GET anymore, I'm not sure why. If I put the old rule, I get the same behavior again.

 

 

Coordinator
Dec 14, 2010 at 1:15 PM

Well I'm glad you're working things out.

You can test out your pattern like this:   ^(.*)/rest/customer(/.*)*$      using the testdriver or using a Regex tool like those I mentioned in the IIRF documentation.

Dec 14, 2010 at 2:18 PM

OK. Thank you very much.