Download a file with a parameter in URL - apache

I noticed that downloading a file on a Apache server with:
example.com/myfile.zip?parameter=2365
gives exactly the same result / same downloaded file / same downloaded filename on client browser as downloading:
example.com/myfile.zip
Is it a supported and documented feature of Apache?
I am happy with it, and this will be useful for tracking purposes (I can ship download links with parameters ?source=email and then I will be able to see the parameter in Apache logs, this is useful!), but I wanted to be sure it will work on all browsers (Chrome, Firefox, IE, Safari, etc.)
Note: Are we sure that on most browsers, the downloaded file will have filename myfile.zip and not myfile.zip<somechar>parameter=2365? I tried wget example.com/myfile.zip?parameter=2365 and unfortunately the filename on disk is myfile.zip?parameter=2365, so it doesn't work well with wget.

It's a query string, if there's nothing configured to analyse the parameters then the server will just return the file.
As you've noticed, the Apache logs will include this information if they are configured to. It's perfectly safe to use that syntax, it is defined as part of the URI specification.

Related

Browser Caching Versions in Google Chrome with Tampermonkey

I have a question about caching versions of imported files (via web requests) in Google Chrome:
Let's say I have script.js, whose URL is:
http://www.getscripts.com/script.js (URL contents arbitrary after "http://", because TamperMonkey imports over the HTTP protocol)
If I import the script in Tampermonkey using #require, I want to use a query string for its version to avoid caching.
Caching versions:
Let's say, that I first #require the 1st "version" of the script (created it, and inserted initial content), by giving the require a URL of http://www.getscripts.com/script.js?v=1, so I pass in the URL a query string of the version v=1, and that the script file of version v=1 was not cached already.
I make some changes to the code of script.js, and the script that the URL provides also gets updated (I use surge.sh).
Then, I change my #require URL to: http://www.getscripts.com/script.js?v=2, so I pass in the URL a query string of the version v=2
Then I make some more changes in the code, make sure the URL gets the updated file, and give the #require my initial URL with v=1: http://www.getscripts.com/script.js?v=1
Question:
The script file that will be returned (via an HTTP request) - will it be of version 1, or 2?
What I'm doing is trying to force-download a new version of my script file, after I update the script's code, since Tampermonkey caches script files without re-downloading them, unless there was some changes made in the URL of the #require (what does the HTTP request).
This was solved by forcing the browser to download a new version of the script by adding a version parameter to the script's URL, as suggested by wOxxOm above.

s3 never-ending pending audio requests

I have an mp3 file on s3 (and have experienced with many other mp3 files) that is not playing in chrome (and other browsers as well: FF, safari, etc). The network dialog in chrome shows that there is a pending request that is seemingly never responded to by s3, however if I do a wget to the URL, I get an immediate response.
Additionally, if I serve the exact same file off of a server running nginx, I can access the URL in chrome as well instantaneously. I know that S3 does support byte range requests, so there should be no issue with chrome's byte range queries. Additionally, I've verified that the file is accessible, and that its content type is audio/mpeg.
Here is the file in question:
http://s3.amazonaws.com/josh-tmdbucket/23/talks/ffcc525a0761cd9e7023ab51c81edb781077377d.mp3
Here is a screenshot of the network requests in chrome for that URL:
I solved this by creating a CloudFront distribution. You need to create a distribution for your bucket. For example if you have a bucket named example-bucket, go to CloudFront and click on create distribution. Your bucket will appear in Origin Domain Name as example-bucket.s3.amazonaws.com
Now you can use example-bucket.s3.amazonaws.com url to load content.
This worked for me but I am not sure if it will work for others.
Had same exact issue with files.
Original url looked like this =>
https://my-bucket-name.s3-eu-west-1.amazonaws.com/EIR.mp4
Added CloudFront distribution and it solved all my issues.
Url changed only a bit:
https://my-bucket-name.s3.amazonaws.com/EIR.mp4
(but you can modify it a little while creating distribution / even setting your own DNS if you wish).

Zend server CE - Will not load .php file rather downloads it

I installed Zend Server CE on Windows 8. When I try to load a .php file in my browser it does not load but downloads the php file instead.
My root for the server is C:\Program Files (x86)\Zend\Apache2\htdocs\
I looked everywhere on the web but there is no documentation.
I would recommend against having your document root in program files because of all the security. Reinstall it outside of program files and it might/will probably work.
How do you invoke the file? You cannot use the full windows path there ie: c:\Zend\apache2\etc.. But probably localhost/yourfile.php or 127.0.0.1/yourfile.php. Can you open zend's interface at localhost:100081?
If you get a internal server error well then it serves php files. Now enable errors in php.ini and find out what is wrong probably some path. You are getting a php error and they are set to not display so you get the server error. That does mean php files are parsed by apache and not downloaded. This question here on so has pretty much what you need to configure.
Just remembered you had the zend-framework tag so you could check in application.ini for error handling settings.

Apache/PHP Setting to make .php suffix optional

I noticed on Rackspace, when using an Ubuntu instance (10.04; standard LAMP setup), the ".php" suffix on a URL is optional. ie www.example.com/thispage loads thispage.php
When I setup a very similar server on Amazon (default AWS 32-bit ami; a flavor of CentOS/Red Hat) and locally on osX 10.6, the ".php" suffix is required. www.example.com/thispage returns a 404 error, while /thispage.php loads the file as expected.
The most likely cause, in my mind at least, is that there are different default settings in php.ini or the Apache configuration between these different setups, but I can't figure out what it is. Can anyone explain to me where this difference comes from?
NOTE: I know this can be overcome using mod_rewrite, I'm just curious as to this difference in the default configurations.
Check if the MultViews-Option is set.
If it does, and there is no directory like this(e.g. "thispage") , the server will look for files with the filename "thispage" and any extension and deliver(if any found) the best match.
the answer is this http://www.php.net/manual/en/security.hiding.php#45896 , but you're going to need to access httpd.conf file

File not found - Google Safe Browsing Lookup API

I try to make a browser call to
https://sb-ssl.google.com/safebrowsing/api/lookup?
With and without the API key, etc, but each time and no matter what I do, I get:
File not found
Firefox can't find the file at https://sb-ssl.google.com/safebrowsing/api/lookup?.
Check the file name for capitalization or other typing errors.
Check to see if the file was moved, renamed or deleted.
Any ideas what might be the problem?
The URL you are using is AFAIk from the Google Safebrowsing API V 1 which used to support GET requests and is now deprecated (and will be taken offline by December 1st) - I strongly recommend switching to V2 of the API which from what I gather only supports requests via POST.
EDIT:
SORRY - I overread the "Lookup" part...
I just checked the URL you gave... From Firefox (latest version) I can confirm what you describe... OTOH when I try it via IE the result is different - it comes back with HTTP 403 which I assume is due to the fact that I don't have a valid key...
I can only conclude that Firefox does something Google won't accept - it can be related to User agent or whatever... have you tried this with a simple wget or some http client component/class ?