I am facing an issue on sending http request using wininet api using when the request is sent through a proxy server.
I have an mfc application which sends a requests to a server.
for sending request is use
HttpSendRequest
function of wininet.
I need a file to be uploaded using this. for that 3-4 requst has to be sent related to each file.
When there is a proxy i cant upload more than 3 files at a time.
After that the requests is not sent properly.
Once it is blocked all the requests sent after that doesn't get proper response(some exception occurs).
I have done adding proxy credentials using
InternetSetOption(hConnect, INTERNET_OPTION_PROXY_USERNAME, (LPVOID)lpUname, nUnameBuffer);
InternetSetOption(hConnect, INTERNET_OPTION_PROXY_PASSWORD, (LPVOID)lpPswrd, nPswrdBuffer);
when the application is restated then its ok for the next 3 files.
also its working fine if the proxy settings are disabled.
Any one know why this occurres?
is there any limit for request using wininet functions under a proxy?
please help how to solve this issue.
hellpp me plzzzzz
thanks in advance.
The MS Support article "How To Handle Proxy Authorization with WinInet" suggest that you need to respond to HTTP_STATUS_PROXY_AUTH_REQ with adding authentication data and re-sending the request.
Related
I just deployed an application into cloud run, but the application running in cloud run can't handle the request in the form of POST method and always returns 404 not found. After I checked the log, whatever request was given it was always translated into the get method. What should I do to prevent the given method from being translated like that?
the log:
Notice the HTTP 302 response on your POST. That means the client is being instructed to go to a new Location. Your client is then converting the POST into a GET and making another request at the new location.
Cloud Run only supports HTTPS. Your POST request is being sent to an HTTP endpoint. The Cloud Run frontend will automatically redirect the client to the HTTPS endpoint.
Change your request from using HTTP to HTTPS.
I am running two identical API requests to a 3rd party API -- one in postman and the other in NodeJS. The API responds with different set-cookie headers in Postman vs NodeJS.
I've tried:
Copying the headers from Postman headers tab into my nodejs request headers.
Copying headers from the Postman console logs into my nodejs request headers.
Copying Postman's auto-generated axios code.
node-fetch instead of axios.
Turning various settings on/off in Postman.
Every time, the API request in Postman responds with a different set-cookie header than NodeJS. The postman request is receiving the correct session token while the NodeJS request is not.
The API server can somehow tell the difference between the two environments, but how?
Is postman running on a headless browser so that it can "fool" a server checking for browser runtime?
Is postman a true "curl" while nodejs requests are not?
Given that the request headers and body are the same in both requests, which variables might be used to differentiate between a postman request and nodejs request?
I'll answer this myself, for anyone who comes here searching for answers. Apparently, Postman uses some magic configuration to make requests from the browser while bypassing CORS issues.
They call it the "Postman Agent". It seems like it's probably a local proxy in front of a headless browser with CORS turned off (or something along those lines).
You can read about it here: https://blog.postman.com/introducing-the-postman-agent-send-api-requests-from-your-browser-without-limits/
In my case, the issue wasn't caused by a difference between the requests. It was caused by the way the responses were handled. Postman was showing cookies received in an initial 302 response, and then following the redirect. The NodeJS request was following the redirect but not showing the initial 'set-cookie' header in the final response. As soon as I set redirect: 'manual' in nodejs, I could see the correct headers from the initial 302 response.
I'm currently using a framework in Node.js ( the botbuilder module from Microsoft Bot Framework) which uses the request[2] module to make HTTP requests.
I'm encountering a problem : this framework seems to send a malformed JSON to Microsoft's servers, but I fail to see why and what is this JSON message made of.
So I'm looking for a way to log those messages, to take a peek at this malformed JSON, as I don't have access to the request object (unless I heavily alter the framework code, which is not something one shall do)
So far, I'm able to log the response body (by adding request to the NODE_DEBUG environment variable), but not the original request body. I did try a tcpdump on our server but since it's all HTTPS there's nothing I can use there.
Any idea / tool that might help ?
Thanks for your time.
Use Node.js middleware to log all your requests. For example, you could use the module request-debug.
Another popular request logging middleware worth knowing about is Morgan, from the Express.js server team.
I have developed a front-end interface using Aja(AngularJS) and HTML5. Right now, I send an HTTP get request to my backend server which returns some data based on the GET parameters.
Since the URL is exposed in the Javascript file, I believe anyone could just use the URL to create there own API to fetch the data. How can I prevent such things ?
One way I could think of is that now instead of directly sending the request to the backend server, an application server could be used (hosting the HTML as well). The Ajax request would then be sent to this server (PHP script ?) which would in turn forward the request to the backend server and return the result to the UI. To prevent 3rd party services, I can disable cross origin requests on my application server.
Is this the correct way to solve my problem or are there better ways to do this? I am concerned that this would unnecessarily create another hop (internal though) for requests.
Note: The backend is running Apache Tomcat
In APIs that are not open to the world the user has to authenticate first in order to use it, see for example https://stripe.com/docs/api#authentication or http://dev.maxmind.com/geoip/geoip2/web-services/ -> Authorization
I have a very strange problem with post data being lost in transit. The log-in form for our ASP web app has a for submitting the username / password. The ASP page then receives this post, checks the credentials, and re-directs successful log ins. The problem I'm seeing is that intermittently the post data is just dropped. The request appears on the server, but there is no data. Client side is IE8, server side is IIS running ASP. The user will be fine for a time, and then as soon as they get his error, they have to restart the machine to solve it. What could be causing this and what type of diagnostics can I run to locate the problem?
Use Fiddler tool for inspecting client-server http communication. Maybe something is dropping data between client and server.
You can save each request which you receive in server in some file and to see if they really does not send you nothing. Try to see IIS log for error. Maybe your IIS is busy with other requests and refuse to accept this one. Than it will send 500 error to the client.