xcode Unsupported URL when sending request - php

I am trying to send a GET Http Request to my computer that runs an Apache server.
When I send the request from XCODE to X.X.X.X\my_script.php using sendSynchronousRequest I get a response - Unsupported URL.
However, if I try to connect to this address using my browser it works fine.
Any suggestions? does it not support an address which contains IP?

Change slash in your request: X.X.X.X/my_script.php

Related

Headers sent in curl request from php are working on one server and not on another

I have a weird problem, sending curl request with headers from one server abc.com to another server xyz.com are working while they are not working with another server xyz1.com and its not a subdomain.
I am getting 400 bad request error from xyz1.com server.
Can you help me to get clue what needs to be added to curl request code or need to change in server settings?

Post request missing payload

I'm building an api that receives incoming webhooks from external parties. Post requests to my application lack a body in some cases. In my logs I see the incoming request with the following header:
Accept: */*
Content-Length:
Content-Type: application/json
As you can see the content-length is empty.
I cannot reproduce the problem. What I've tried thus far:
The request payload is only missing coming from a specific third party. If however, I provide this third party with a different callback url like request bin, the payload is not missing.
Connected this party source to our test environment. Which has exactly the same configuration (checked the entire php.ini) and the same version of our software. On our test server, requests are received with payload.
When sending post requests with Postman to our production environment, webhooks are received with payload.
Both test and production are https. I've tried sending http requests to our production server to see what happens, and I get an error as expected and no received headers in our logs.
Checked the php post_max_size, which is on 24M.
When creating a callback.php file in my public folder, and have the third party send it's webhooks to this destination, I am able to write the results to a log with the following code, which includes a payload. If I to output php://input later on in my Laravel application, it doesn't work:
$postdata = file_get_contents("php://input");
$file = fopen("webhook.log","w");
echo fwrite($file,$postdata);
fclose($file);
Both servers are running on the same php version (php7), and I am at a loss as to what to try next.
Found it! The problem was a port 80 to 443 redirect in a vhost configuration. I earlier dismissed redirects - which seem to be a common source of missing payloads in post requests - as possible cause; I had made a test script which succesfully received payloads on this very same server.
However, I had placed this test script in the servers public folder, which was not subject to the same redirects as was the root of my application. After removing the redirect, payloads where received as expected.

Angular $http PUT requests return status -1

I have a PHP REST API running on Apache2 Webserver inside an Ubuntu machine.
I'm trying to send PUT requests to my server with no success.
When I'm sending the request inside my localhost (same origin) - it works.
When I'm sending the request on my Docker containers (same origin) - it works.
When I'm sending the request from my Angular client to the server in development environment (cross-origin) - I received a weird status -1 error in the return of the request.
From sending the request from PostMan Chrome Extension - it works perfectly, but I see nothing special in its request headers.
This is my code for sending the request:
return $http.put(path, params).then(successCallback, errorCallback);
This is a picture of the returned status:

Ajax Request Rejected

I am trying to upload a file using an (jquery) AJAX request but it fails and the response sent is
Request Rejected
The requested URL was rejected. Please consult with your administrator.
Your support ID is: xxxxxxxxxxxxxxx and provide steps to replicate the issue
I've tried to visit the URL using browser and that works fine.
Is there anything related with the AJAX request or is it entirely a server side issue? How can I solve this?
Your message is being generated by a Big IP ASM
When an Illegal HTTP status violation occurs, the BIG-IP ASM sends an HTTP blocking response page that includes the OWS Server header.
So the problem is not on your side, it's on the web server side.
When origin in request header is null, server doesn't allow request. read about CORS at http://en.wikipedia.org/wiki/Cross-origin_resource_sharing Cross Domain request can be allowed from php server as
header("Access-Control-Allow-Origin:*");
and enable all methods for request.
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");

CURL request clarification

I am calling below file in below 2 ways:-
1. CURL request
2. Ajax request in web site
http://test.com/test.php
In that scenarios , How to find out the file request comes from CURL / Ajax request without argument segregation.
Please suggest.
You can compare the request IP address. The Ajax call request IP address will be the client's IP address, while on the CURL case it will be the server(or where the library is located) IP address.
You can check the user-agent header. If starts with curl, indicates that the request was from a curl client.
Use the code $_SERVER['HTTP_USER_AGENT']; to get the user agent.

Categories