http-headers

Issue with content type in Spring

扶醉桌前 提交于 2019-12-12 03:09:48
问题 I have an issue with a POST that I am receiving. I have the following endpoint: @RequestMapping(value = "/payment", method = POST) public void saveOrder(@RequestBody PaymentDto paymentDto) throws RequiredFieldException, IOException, MessagingException { //do something } Now, when someone send me POST on this URL, I get the following in response: {"errorMessage":"Unsupported Media Type", "errorId":"906f5dc8-0b79-4f91-9eaa-a252e8d5ac76", "errorDetails": {"message":"Content type 'application/x

Redirect Users based on IP Address | Apache / htaccess

一世执手 提交于 2019-12-12 03:03:10
问题 I'd like to redirect users to an /index/ area of the site if they don't have my IP address. How do I do this? Thank you. 回答1: The mod_rewrite way: RewriteEngine on RewriteCond %{REMOTE_ADDR} ^123\.45\.67\.[8-9]$ # your ip here RewriteCond %{REQUEST_URI} !^/index/ RewriteRule .? /index/ [R,L] 回答2: Is this what you're looking for? if($_SERVER['REMOTE_ADDR'] != 'xxx.xxx.xxx.xxx') { header('Location: /index/'); } You can specify an array that matches against allowed IPs. if(!in_array($_SERVER[

How to make sure the Cookie is set before a new request is made?

倖福魔咒の 提交于 2019-12-12 02:50:01
问题 I have an issue that should be fixed on the server side, but a quick workaround on the client side would be acceptable. I need to make a JS call after the page is loaded and the http-only secure cookie is already set. I'm using window.onload event to call window.location.replace(), but even though the page is loaded with the SET-COOKIE HTTP response header, the new request doesn't send the cookie. How to make sure the Cookie is set before a new request is made? 回答1: A workaround that works

Unable to render excel download from aspx page

旧城冷巷雨未停 提交于 2019-12-12 02:34:07
问题 I have an ASP.NET (webforms) page that renders MS-Excel back to the response stream on click of a button. Everything works perfectly in testing but on live deployment, I get this dialogue box after the browser appears to be trying to download the file: where ReportsShow.aspx is the name of the aspx page that generates and renders the excel. The button that triggers the download fires a postback so I am confounded as to why the page would not be found when it renders correctly on load? I am

Get redirect location of URL list

大憨熊 提交于 2019-12-12 02:31:49
问题 I have a txt file with a list of URLs. I want the redirect locations of all the URLs in that list. Here is my code: $url_list = "ggurl.txt"; $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); foreach (file($url_list) as $url) { curl_setopt($ch, CURLOPT_URL, $url); $out = curl_exec($ch); // line endings is the wonkiest piece of this whole thing $out = str_replace("\r", "", $out); // only look at the headers $headers_end = strpos($out, "\n

FB API Cookie Header Error

你。 提交于 2019-12-12 01:59:52
问题 I have the following code: require '../lib/facebook-php-sdk/src/facebook.php'; $facebook = new Facebook(array( 'appId' => '143944345745133', 'secret' => 'xxxxxxxx', 'cookie' => true, )); $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { $user = 0; } } if ($user) { setcookie('loggedUserId', $user, time()+36000); setcookie('loggedUserName', $user_profile['name'], time()+36000); } else { setcookie('loggedUserId', '', time(

PHP: How to read POST body with Transfer-Encoding: chunked, no Content-Length

一世执手 提交于 2019-12-12 01:47:01
问题 I am writing a service to receive data from an energy monitoring device in my house. The only way the device can push data is by using an HTTP POST , with Transfer-Encoding: chunked , and no Content-Length , and the data as XML in the request body. I would like to be able to read this data in a PHP script (behind Apache) and store it in my database. It appears that the most correct way to read the HTTP request body in PHP these days is to open and read php://input . However, comments from

Add “referer” to header when using ShellExecute

人走茶凉 提交于 2019-12-12 01:38:35
问题 I'm using ShellExecute to open the user's default browser to a specific web site. I'd like to add a referer field to the URL. Is this possible to do while continuing to use ShellExecute? If not, any other suggestions to get a users default browser to open a URL with referer? 回答1: The referrer is part of the HTTP protocol. ShellExecute opens an app which then processes the URL, by sending an HTTP request. It's that app that specifies the referrer. The very best you could do would be to include

Why do I receive this error: The remote server returned an error: (417) Expectation Failed

别说谁变了你拦得住时间么 提交于 2019-12-12 01:37:03
问题 A friend show me this sample code to implement HTTP POST in C# and did work out in a WINFORM App: http://www.terminally-incoherent.com/blog/2008/05/05/send-a-https-post-request-with-c/ And implemented in a METRO APP: // this is what we are sending string post_data = "user=user@example.com&pass=example123"; // this is where we will send it string uri = "http://app.proceso.com.mx/win8/login"; // create a request HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Method =

HttpRequest header “X-Forwarded-Proto” missing

旧时模样 提交于 2019-12-12 01:25:38
问题 We have a load balancer for IIS ASP.NET Web Application which forwards all the https requests as http . Hence we required the X-Forwarded-Proto header to identify https. I'm able to see X-Forwarded-For header but not the Proto . I'm checking in Request.Headers Is there something missing or any alternative to know the original request was https ? 回答1: X-Forwarded-Proto header is explicitly set by the Load Balancer through IRule . As the IRule was not being applied X-Forwarded-Proto header was