http-headers

Download external file with PHP fopen and/or cURL

萝らか妹 提交于 2019-12-11 04:38:51
问题 I can't get my download script to work with external files, the file will download but is corrupted/not working. I think it's because I can't get the filesize of the external file with filesize() function. This is my script: function getMimeType($filename){ $ext = pathinfo($filename, PATHINFO_EXTENSION); $ext = strtolower($ext); $mime_types=array( "pdf" => "application/pdf", "txt" => "text/plain", "html" => "text/html", "htm" => "text/html", "exe" => "application/octet-stream", "zip" =>

“Bad Gateway Error 502” when trying to download server-generated .zip file

╄→гoц情女王★ 提交于 2019-12-11 04:32:40
问题 I'm getting a "bad gateway error 502" when trying to download a server-generated .zip-file I've isolated the line that causes the error; it's: $zip->addFile($thumb->loadVersion($version['id']), $rank . "_" . $thumb->filename); Here's my code. My script loops through all the .jpg files users have uploaded, bundles them into one big .zip file, and sends download headers for the .zip file. function downloadGalleryZip() { $tmpfile = tempnam("tmp", "zip"); $zip = new ZipArchive(); $res = $zip-

IE adding content-type multipart/form-data to GET requests

百般思念 提交于 2019-12-11 04:04:57
问题 I have a form like this: <form method="POST" enctype="multipart/form-data"> <input type='submit' name='foo' /> </form> When that form is submitted, I have some PHP that renders an image: <img src="http://s3-external-1.amazonaws/bucket/example.jpg?AWSAccessKeyId=foo&Signature=bar&expires=111111" /> The problem is that Internet Explorer 11 (and other versions I believe) are sending a Content-Type: multipart/form-data; boundary=---------------------------7dfcd3b0f0a on that GET request. When AWS

Is there any way to detect if a user agent is from a browser or an app?

孤街浪徒 提交于 2019-12-11 04:03:22
问题 I need to differentiate whether a User-Agent string from an HTTP header is from a mobile (iOS & Android) browser or a app. Is there any tool/library, preferably in Python which can help me with that? 回答1: user-agents is a fairly simple package for Python, which parses the User-Agent string. from user_agents import parse user_agent = parse(user_agent_string) user_agent.os.family # This will get you what you need So having the OS family you can judge whether the request is made from a desktop

How to retrieve the authorization token from the response header of an ajax call in angularjs?

丶灬走出姿态 提交于 2019-12-11 03:51:21
问题 Basically the title has described everything. I send an api call, get a response, with Authorization in the header, and I want to retrieve this authorization token from the header because it is needed for subsuquent api calls. How should I get this info? 回答1: You should take a look here: https://docs.angularjs.org/api/ng/service/$http $http.get('yourUrl'). success(function(data, status, headers, config) { console.log(headers); }) 回答2: $http passes headers to the success/error callbacks. The

With php cURL get filename from file header

一个人想着一个人 提交于 2019-12-11 03:51:10
问题 I have this php cURL function: function curl_login($url,$data,$proxy,$proxystatus){ $fp = fopen("cookietlt.txt", "w"); fclose($fp); $login = curl_init(); curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($login, CURLOPT_TIMEOUT, 40); curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE); if ($proxystatus == 'on') { curl_setopt($login

Is it valid to leave Accept-Encoding field empty?

浪尽此生 提交于 2019-12-11 03:47:30
问题 I found the example of Accept-Encoding violates the specification in the document: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14#sec14.3 The "Accept-Encoding" header field is defined as below: Accept-Encoding = "Accept-Encoding" ":" 1#( codings [ ";" "q" "=" qvalue ] ) So according to the syntax of 1#(...) , it should contain at least one element in the value list. But one of the examples comes after it is: Accept-Encoding: It has a blank value part. Did I miss anything? And could anyone

ServiceStack, CORS, and OPTIONS (No Access-Control-Allow-Origin header)

你离开我真会死。 提交于 2019-12-11 03:39:30
问题 We're hitting a bit of a snag with CORS features of a restful API in ServiceStack 4. We want to be sneding cookies to the api since the SS session is in the cookies, so we make AJAX calles with "WithCredentials" = true in our angular clients that hit the API. Since Chrome (at least) doesn't like Access-Control-Allow-Origin wildcards with WithCredentials, we've added a pre-request filter to echo back the requester's origin in the Access-Control-Allow-Origin header like so: private void

Serve file to user over http via php

做~自己de王妃 提交于 2019-12-11 03:38:50
问题 If I goto http://site.com/uploads/file.pdf I can retrieve a file. However, if I have a script such as: <?php ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); //require global definitions require_once("includes/globals.php"); //validate the user before continuing isValidUser(); $subTitle = "Attachment"; $attachmentPath = "/var/www/html/DEVELOPMENT/serviceNow/selfService/uploads/"; if(isset($_GET['id']) and !empty($_GET['id'])){ //first lookup attachment meta information $a = new

Handling “If-None-Match” header with angular resouce?

萝らか妹 提交于 2019-12-11 03:31:07
问题 I have an angular app which talks to my rails api via ng resource. In my response I set etag in my header which I get in my response headers but while making the same query again If-None-Match header is not set and in turn my caching doesn't works whereas when i make requests directly via the browser it works correctly. How can I set the received etag in my request headers with $resource 回答1: $resource doesn't natively support etags, one way of doing it is using $cachefactory and interceptors