Jeff-Lewis / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Minify returning 400 Bad Request #78

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Minify version: 2.1.1
PHP version: 5.2.7

What steps will reproduce the problem?
1. Installing
2. Creating configuration file (attached)
3. calling via any method.

Expected output:

Minified output of js / css file(s).

Actual output:

400 Bad Request

Did any unit tests FAIL? Unknown.

Please provide any additional information below.

Request Headers:

Host: www.devbrewards.co.uk
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.5)
Gecko/2008120122 Firefox/3.0.5 (.NET CLR
 3.5.30729)
Accept: text/css,*/*;q=0.1
Accept-Language: en-gb
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.devbrewards.co.uk/
Cookie: CAKEPHP=gr62h029k2buteruujlcb6fnn0;
SESS55e30b91742880ca57848b3a725fc4b3=vnashmcr3vasft9c08divi9me2

Response Headers:

Date: Wed, 21 Jan 2009 09:57:01 GMT
Server: Apache/2.2.10 (Win32) PHP/5.2.7-dev
X-Powered-By: PHP/5.2.7-dev
Content-Length: 24
Connection: close
Content-Type: text/html; charset=UTF8

Response: HTTP/1.0 400 Bad Request

Original issue reported on code.google.com by ibnorme...@gmail.com on 21 Jan 2009 at 10:01

Attachments:

GoogleCodeExporter commented 9 years ago
Only issue I see is:

$min_cachePath = 'c:\\WINDOWS\Temp';

should be:

$min_cachePath = 'c:\\WINDOWS\\Temp';

Does this help?

Original comment by mrclay....@gmail.com on 21 Jan 2009 at 9:43

GoogleCodeExporter commented 9 years ago
1. after not work at all

2. my adds to config

$_SERVER['DOCUMENT_ROOT'] = substr($_SERVER['PATH_TRANSLATED'], 0,
strlen($_SERVER['SCRIPT_NAME']) * - 1);

$_SERVER['REQUEST_URI'] = $_SERVER["SCRIPT_NAME"];
if ( $_SERVER["QUERY_STRING"] != "" ){ $_SERVER['REQUEST_URI'] =
$_SERVER['REQUEST_URI'] . "?" . $_SERVER["QUERY_STRING"]; };

( server is iis 6.0, module php 5.1.6 )

3. test_all - good
4. http://www.denisx.ru/min/index.php?f=_css/stylesheet.css - Bad request

wtf?

Original comment by deniskhripkovv on 24 Jan 2009 at 12:35

Attachments:

GoogleCodeExporter commented 9 years ago
i'm also having this problem with apache... will post if i find a solution.

Original comment by sdew...@gmail.com on 25 Jan 2009 at 8:22

GoogleCodeExporter commented 9 years ago
I had the same problem and the builder wasn't showing either. I got it to work 
by
specifying the sub-domain root as the document root in config.php like this:

if(array_key_exists('SUBDOMAIN_DOCUMENT_ROOT', $_SERVER)){
    $_SERVER['DOCUMENT_ROOT'] = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
}

I'm working with an Apache server and when I initially got the "Bad Request" 
error I
checked to see what $_SERVER['DOCUMENT_ROOT'] contained. I then combined this 
with
the path to a CSS file and tested with is_file(). The file wasn't found.
So I added a PHP file in the same directory as the CSS file which printed the
contents of $_SERVER. I found out two important things:
1. The DOCUMENT_ROOT was one folder short of the actual path to the CSS file.
2. The actual path was contained in SUBDOMAIN_DOCUMENT_ROOT.

I added the code above and it worked.

I could also have added the missing folder like this:

$_SERVER['DOCUMENT_ROOT'] .= '/folder';

However, I found the first option to be a little more solid and neater.

This approach may not solve everyone's problems primarily because
SUBDOMAIN_DOCUMENT_ROOT may not be available as a standard on all servers. But 
I hope
it gives direction on where to look for the problem.

Anyway, it worked. And I really had to get it to work because Minify is exactly 
what
I needed. Minify ROCKS!!! Thanks Mr. Clay.

Bleezapheronn,

Nairobi, Kenya

Original comment by Jeffrey....@gmail.com on 25 Jan 2009 at 8:27

GoogleCodeExporter commented 9 years ago
Hey cool, I got it working.  I'm using CakePHP and they have a mod_rewrite rule 
in
the DocumentRoot that looks like this:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

I had put minify in my app/webroot directory when I got the 400 bad request 
errors. 
What I did is change the DocumentRoot in my Apache conf file to point to the
app/webroot directory (which I think is how CakePHP prefers to be setup anyway) 
and
reloaded the configuration... presto, it works!

Thanks Nairobi for the help and thank you Mr. Clay for this wonderful program!

Original comment by sdew...@gmail.com on 25 Jan 2009 at 8:59

GoogleCodeExporter commented 9 years ago
Anyone still having trouble with this issue should try this beta release:
http://groups.google.com/group/minify/browse_thread/thread/8add5761eb27d67d

Original comment by mrclay....@gmail.com on 26 Jan 2009 at 6:48

GoogleCodeExporter commented 9 years ago
omg.

install new ver

config change

$_SERVER['DOCUMENT_ROOT'] = 'd:\\hst\denisx-ru_b0d8d0fb\\http';

$_SERVER['REQUEST_URI'] = $_SERVER["SCRIPT_NAME"];
if ( $_SERVER["QUERY_STRING"] != "" ){ $_SERVER['REQUEST_URI'] =
$_SERVER['REQUEST_URI'] . "?" . $_SERVER["QUERY_STRING"]; };

http://www.denisx.ru/min_unit_tests/test_all.php - good
http://www.denisx.ru/min/index.php?f=_css/stylesheet.css - Bad request

? 

Original comment by deniskhripkovv on 27 Jan 2009 at 10:03

GoogleCodeExporter commented 9 years ago
@denis: If you're now using 2.1.2b, replace the config code you added with this:

$min_documentRoot = 'd:\\hst\\denisx-ru_b0d8d0fb\\http';

This is mentioned in the new upgrade instructions:
http://code.google.com/p/minify/source/browse/trunk/UPGRADING.txt?r=283#18

Minify shouldn't need $_SERVER['REQUEST_URI'] at all.

Original comment by mrclay....@gmail.com on 27 Jan 2009 at 12:30

GoogleCodeExporter commented 9 years ago
I just committed a unit test update that might shed more light on your problem. 
Just 
replace your min_unit_tests folder with this one:
http://mrclay.org/min_unit_tests_r284.zip

Original comment by mrclay....@gmail.com on 27 Jan 2009 at 4:06

GoogleCodeExporter commented 9 years ago
i confused :)
now install ver 2.1.1
http://denisx.ru/min_unit_tests/test_all.php - bad
and (r284.zip) http://denisx.ru/min_unit_tests_new/test_all.php - bad

adding $min_documentRoot = 'd:\\hst\\denisx-ru_b0d8d0fb\\http'; change nothing

where can i download 2.1.2? =)

Original comment by deniskhripkovv on 31 Jan 2009 at 2:11

GoogleCodeExporter commented 9 years ago
2.1.2b: see http://groups.google.com/group/minify/browse_thread/
thread/8add5761eb27d67d

Original comment by mrclay....@gmail.com on 31 Jan 2009 at 4:27

GoogleCodeExporter commented 9 years ago
2.1.2b

$min_documentRoot = 'd:\\hst\\denisx-ru_b0d8d0fb\\http';

http://www.denisx.ru/min_unit_tests/test_all.php - bad :(

Original comment by deniskhripkovv on 1 Feb 2009 at 7:16

GoogleCodeExporter commented 9 years ago
@denis:
Since you're on Windows, "/tmp" is not a valid cache path. The easiest fix is 
to 
comment out $min_cachePath and let Minify guess a path to use. If that doesn't 
work 
you'll have to figure out a writable directory.

It also looks like $_SERVER['REQUEST_URI'] is not being set on your server, so 
you'll need this code in config.php:

// from http://davidwalsh.name/iis-php-server-request_uri
$_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 1);
if (isset($_SERVER['QUERY_STRING'])) {
    $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
}

Original comment by mrclay....@gmail.com on 2 Feb 2009 at 2:01

GoogleCodeExporter commented 9 years ago
request to close issue as is configuration problem, rather than bug / defect.

Original comment by ibnorme...@gmail.com on 2 Feb 2009 at 3:04

GoogleCodeExporter commented 9 years ago
@ibnormedia: Agreed.
@denis: Please use the mailing list for further support on this issue.

Original comment by mrclay....@gmail.com on 2 Feb 2009 at 3:58

GoogleCodeExporter commented 9 years ago
tmp is there. but not working. 
$_SERVER['REQUEST_URI'] include.

$min_cachePath = preg_replace('/^\\d+;/', '', session_save_path()); is working

but now next problem: !WARN: environment : Local HTTP request failed. Testing 
cannot
continue.

http://www.denisx.ru/min_unit_tests/test_all.php

Original comment by deniskhripkovv on 2 Feb 2009 at 4:05

GoogleCodeExporter commented 9 years ago
This issue is closed. Use the mailing list for support:
http://groups.google.com/group/minify

P.S. Install FirePHP and enable error logging to see what's going on. See the 
config 
file in 2.1.2b for details.

Original comment by mrclay....@gmail.com on 2 Feb 2009 at 5:21

GoogleCodeExporter commented 9 years ago
In my case I have similar problem (with 2.1.2)

"!WARN: environment : Local HTTP request failed. Testing cannot
continue."

 but disabled 'allow_url_fopen' in php.ini was guilty, must be Turn On ;)

Original comment by SmallPar...@gmail.com on 1 Mar 2009 at 11:15

GoogleCodeExporter commented 9 years ago
@SmallPartOfEternity: 'allow_url_fopen' is not needed for operation of Minify, 
only 
unit testing. Unless you need it for other scripts, you should disable it after 
resolving your other issues.

Original comment by mrclay....@gmail.com on 2 Mar 2009 at 2:00

GoogleCodeExporter commented 9 years ago
I had a similar problem and went back to basics to fix it:

Make sure that:
1.  the file exists (auto-copying wasn't working in my IDE)
2.  it is readable by the script environment (chmod 644 [file]), and
3.  the cache directory is writable.

Original comment by komputer...@gmail.com on 26 Dec 2010 at 12:27

GoogleCodeExporter commented 9 years ago
Hi,
Encountered the Response: HTTP/1.0 400 Bad Request error too.
Make sure that you use absolute paths instead of urls.

By mistake I entered whole urls in the builder, this returned no error, I ended 
up with paths like this in the array:

'js' => array('//http://www.example.com/assets/js/jquery.colorbox.js', 
'//http://www.example.com/assets/js/suckerfish.js'),

Changing this to absolute paths fixed the problem..
Should look like this:
'js' => array('//assets/js/jquery.colorbox.js', '//assets/js/suckerfish.js'),

Have fun with Minify!
Quokka

Original comment by i...@kastentafel.nl on 1 Jun 2011 at 7:35

GoogleCodeExporter commented 9 years ago
OMG!!!
BREAKTHROUGH!!!!!
Change in your config file $min_documentRoot
to the correct root for example: $min_documentRoot = 
$_SERVER['DOCUMENT_ROOT'].'/magento' or wherever you have the min folder 
installed
THEN TAKE OUT ALL COMMENTS INSIDE JAVASCRIPT FILES BEFORE THE SCRIPT
OMG so simple no more 400 Bad Requests!!!!!

Original comment by dknzdes...@gmail.com on 22 Nov 2012 at 2:09