Range: bytes 0- FAILS in Apache 2.2.23 - linux

I'm running plesk 9.5.2 on Centos 5 and this apache version:
# apachectl -v
Server version: Apache/2.2.23 (Unix)
Server built: Sep 26 2012 00:02:01
Trying to serve some mp4 files, I've setup mime types correctly but I'm getting this weird behaviour:
# curl -I -s iated.org/inted/video_data/promo.mp4
HTTP/1.1 200 OK
Date: Mon, 29 Sep 2014 16:09:48 GMT
Server: Apache/2.2.23 (CentOS)
Last-Modified: Sun, 28 Sep 2014 09:44:30 GMT
ETag: "21f0070-13079ae-5041cff289b80"
Accept-Ranges: bytes
Content-Length: 19954094
X-Powered-By: PleskLin
Content-Type: video/mp4
Which is OK. Thats what IE10 is requesting. However Firefox and Chrome are doing something fancier and set Content-Range bytes:0- like:
# curl -I -H "Range: bytes=0-" -s iated.org/inted/video_data/promo.mp4
Than returns nothing. Void.
Range requests works otherwise well:
# curl -I -H "Range: bytes=1-" -s iated.org/inted/video_data/promo.mp4
HTTP/1.1 206 Partial Content
Date: Mon, 29 Sep 2014 16:08:41 GMT
Server: Apache/2.2.23 (CentOS)
Last-Modified: Sun, 28 Sep 2014 09:44:30 GMT
ETag: "21f0070-13079ae-5041cff289b80"
Accept-Ranges: bytes
Content-Length: 19954093
X-Powered-By: PleskLin
Content-Range: bytes 1-19954093/19954094
Content-Type: video/mp4
Any idea why apache is panicking with Range: bytes 0- ??

Updating Apache to 2.2.27 solved the issue.

Related

IIS not gzipping large dynamic JSON response

I see other responses from same server getting gzipped. I have a certain URL that is not getting gzipped. I can only think the problem may be the size of the content but I see no setting in IIS 8 that pertains to a size limit.
All static and dynamic and url and http compression is installed and enabled. I can't find any logs that contain any helpful info on why this URL is not getting compressed.
For example, a response that is gzipped from IIS. (See response header Content-Encoding: gzip)
curl 'http://....../small_json/' -H 'Accept-Encoding: gzip, deflate' -H 'Accept: application/json, text/plain, */*' --compressed -D /tmp/headers.txt -o /dev/null; cat /tmp/headers.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 65382 100 65382 0 0 233k 0 --:--:-- --:--:-- --:--:-- 233k
HTTP/1.1 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Content-Encoding: gzip
Content-Language: en
Vary: Accept, Accept-Language, Cookie,Accept-Encoding
Server: Microsoft-IIS/8.5
X-Frame-Options: SAMEORIGIN
Date: Sun, 08 Apr 2018 01:50:54 GMT
Content-Length: 65382
Larger JSON response does not have Content-Encoding: gzip:
curl 'http://....../big_json/' -H 'Accept-Encoding: gzip, deflate' -H 'Accept: application/json, text/plain, */*' --compressed -D /tmp/headers.txt -o /dev/null; cat /tmp/headers.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4755k 0 4755k 0 0 1018k 0 --:--:-- 0:00:04 --:--:-- 1373k
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Content-Language: en
Vary: Accept, Accept-Language, Cookie
Server: Microsoft-IIS/8.5
X-Frame-Options: SAMEORIGIN
Date: Sun, 08 Apr 2018 01:51:11 GMT
I've set compression settings to be very liberal:
FERB info for the compressed response:
FERB info for the non-compressed response:
I don't know if it still rellevant,
But you have to set dynamicCompressionLevel to a high value.
By default is 0.

How do I send an event to Azure IoT Hub via HTTPS

I setup an IoT hub on Azure, and created a device called "ServerTemp". I generated an SAS token, and it seems to be accepted (I don't get 401). But I'm getting a 400 Bad Request.
Here is the request I'm sending via curl:
curl -v -H"Authorization:SharedAccessSignature sr=A794683.azure-devices.net&sig=<snip>" -H"Content-Type:application/json" -d'{"deviceId":"ServerTemp","temperature":70}' https://A479683.azure-devices.net/devices/ServerTemp/messages/events?api-version=2016-11-14
Request and Response (output from curl):
> POST /devices/ServerTemp/messages/events?api-version=2016-11-14 HTTP/1.1
> Host: A479683.azure-devices.net
> User-Agent: curl/7.47.0
> Accept: */*
> Authorization:SharedAccessSignature sr=A794683.azure-devices.net&sig=<snip>
> Content-Type:application/json
> Content-Length: 42
>
* upload completely sent off: 42 out of 42 bytes
< HTTP/1.1 400 Bad Request
< Content-Length: 151
< Content-Type: application/json; charset=utf-8
< Server: Microsoft-HTTPAPI/2.0
< iothub-errorcode: ArgumentInvalid
< Date: Sun, 15 Apr 2018 22:21:50 GMT
<
* Connection #0 to host A479683.azure-devices.net left intact
{"Message":"ErrorCode:ArgumentInvalid;BadRequest","ExceptionMessage":"Tracking ID:963189cb515345e69f94300655d3ca23-G:10-TimeStamp:04/15/2018 22:21:50"}
What am I doing wrong?
Make sure you add the expiry time &se= (as in &se=1555372034) when you form the SAS. It should be the very last parameter. That's the only way i can reproduce the HTTP 400 you're seeing (by omitting it). You should get a 204 No Content once you fix that.
The resource (&sr=) part also seems a bit off in your case, there's no device being specified. Use Device Explorer to generate a device SAS (or just to see how it should look like): Management > SAS Token.
SAS structure —
SharedAccessSignature sig={signature-string}&se={expiry}&skn={policyName}&sr={URL-encoded-resourceURI}
$ curl -i https://poorlyfundedskynet.azure-devices.net/devices/dexter/messages/events?api-version=2016-11-14 \
-H "Authorization: SharedAccessSignature sr=poorlyfundedskynet.azure-devices.net%2fdevices%2fdexter&sig=RxxxxxxxtE%3d&se=1555372034" \
-H "Content-Type: application/json" \
-d'{"deviceId":"dexter","temperature":70}'
HTTP/1.1 204 No Content
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Date: Sun, 15 Apr 2018 23:54:25 GMT
You can monitor ingress with Device Explorer or iothub-explorer:
Probably this would work as well: Azure IoT Extension for Azure CLI 2.0

Extract Date From Long Date - Time Format

I have the following dates and time in a column:
23 Jul 2016 04:36:37 GMT
24 Jul 2016 07:46:12 GMT
26 Jul 2016 05:44:21 GMT
25 Jul 2016 14:25:39 GMT
20 Jul 2016 15:14:42 GMT
22 Jul 2016 11:52:02 GMT
23 Jul 2016 14:31:31 GMT
23 Jul 2016 11:04:36 GMT
12 Jul 2016 22:33:19 GMT
21 May 2016 20:51:54 GMT
8 Jul 2016 07:38:34 GMT
5 Jun 2016 05:00:29 GMT
I would like to get an output in the format MM/DD/YYYY or M/D/Y.
I have tried using the following post as a reference: Removing time element of Long Date Format
However, I can not use =INT(A1) due to the formatting or =LEFT(A1,10) because it may be 10 or 11 characters.
Combine the two:
=INT(--LEFT(A1,LEN(A1)-3))
Since we only need to remove the GMT we don't care how long it is we just remove the last three.
Similar to Scott Craner's answer, you can remove the last the characters ("GMT") and then find the date value as follows:
=DATEVALUE(LEFT(A1,LEN(A1)-3))

cURL Command in linux to return http response code

Please i want to use the cURL command in linux OS to return as a result just the http response code which is "200" if it is okey
am using that command:
curl -I -L domain.com
but this is returning for me a full text like this
HTTP/1.1 **200** OK
Date: Thu, 27 Feb 2014 19:32:45 GMT
Server: Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.4.19
X-Powered-By: PHP/5.4.19
Set-Cookie: PHPSESSID=bb8aabf4a5419dbd20d56b285199f865; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding,User-Agent
Content-Type: text/html
so please i just need the response code and not the whole text
Regards
curl -s -o out.html -w '%{http_code}' http://www.example.com
Running the following will supress the output so you won't have any cleanup.
curl -s -o /dev/null -w '%{http_code}' 127.0.0.1:80
Example above uses localhost and port 80

Microsoft nmake: $? expands but $< does not

I'm trying to compile some third-party code and have hit some strange NMAKE behavior.
The line in the Makefile is
cholmod_aat.o: ../Core/cholmod_aat.c
$(C) -c $(I) $< -Fo$#
which produces the following error:
Wed, Aug 15 2012 23:25:20 ../Include/cholmod.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_blas.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_check.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_cholesky.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_complexity.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_config.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_core.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_internal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_matrixops.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_modify.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_partition.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_supernodal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_template.h
Fri, Aug 17 2012 16:06:24 ../Core/cholmod_aat.c
cholmod_aat.o target does not exist
NMAKE : warning U4006: special macro undefined : '$<'
cl -O2 -nologo -D__MINGW32__ /MD -DNPARTITION -c -I../../AMD/Include -I.
./../AMD/Source -I../../COLAMD/Include -I../../metis-4.0/Lib -I../../CCOLAMD/In
clude -I../../CAMD/Include -I../Include -I../../UFconfig -Focholmod_aat.o
cl : Command line error D8003 : missing source filename
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
Why is nmake saying '$<' is "undefined" when it lists cholmod_aat.c as a dependency right beforehand? Even more confusing is that if I replace $< with $? in the makefile, nmake expands '$?' just fine:
Wed, Aug 15 2012 23:25:20 ../Include/cholmod.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_blas.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_check.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_cholesky.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_complexity.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_config.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_core.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_internal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_matrixops.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_modify.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_partition.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_supernodal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_template.h
Fri, Aug 17 2012 16:06:24 ../Core/cholmod_aat.c
cholmod_aat.o target does not exist
cl -O2 -nologo -D_MINGW32_ /MD -DNPARTITION -c -I../../AMD/Include -I.
./../AMD/Source -I../../COLAMD/Include -I../../metis-4.0/Lib -I../../CCOLAMD/In
clude -I../../CAMD/Include -I../Include -I../../UFconfig ../Include/cholmod.h .
./Include/cholmod_blas.h ../Include/cholmod_check.h ../Include/cholmod_cholesky.
h ../Include/cholmod_complexity.h ../Include/cholmod_config.h ../Include/cholmod
_core.h ../Include/cholmod_internal.h ../Include/cholmod_matrixops.h ../Include/
cholmod_modify.h ../Include/cholmod_partition.h ../Include/cholmod_supernodal.h
../Include/cholmod_template.h ../Core/cholmod_aat.c -Focholmod_aat.o
What is going on?
The answer is on MSDN:
$< - Dependent file with a later timestamp than the current target.
Valid only in commands in inference rules.
It's not in an "inference rule", it's in a "description block", as these things are called in NMAKE.
--- EDIT: Expanding on my original answer ---
The terminology is a little strange so in this case it's easiest to show by example. I created a makefile with 2 rules - a description block (a.k.a. target rule), and an inference rule.
C:\temp>type makefile.txt
c.txt : a.txt b.txt
#echo $?
#echo %s
.SUFFIXES: .log
.log.txt:
#echo $<
I created empty files a.txt, b.txt and d.log for dummy input. Then I ran the makefile on targets c.txt and d.txt:
C:\temp>nmake /f makefile.txt c.txt d.txt
Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
a.txt b.txt
a.txt
d.log
C:\temp>
Hopefully this illustrates the difference between $?, %s and $<. The MSDN documentation is rather terse, but the code really does work as documented. Honest!
You could try the following:
cholmod_aat.obj: ../Core/cholmod_aat.c
$(C) -c $(I) %s -Fo$#
The symbol %s maps to the first dependency in the list

Resources