473,657 Members | 2,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Requesting Compressed Pages?

I have a script for requesting HTTP resources and I want it to use HTTP
compression (to reduce bandwidth), if possible. What's the best way to
do this? I've tried using zlib functions but they always return FALSE.
And I've tried to use the zlib wrapper, which works but makes
non-compressed resources take longer.

TIA.

Jul 17 '05 #1
8 2315
Hello,

On 12/21/2003 11:03 AM, Keith Bowes wrote:
I have a script for requesting HTTP resources and I want it to use HTTP
compression (to reduce bandwidth), if possible. What's the best way to
do this? I've tried using zlib functions but they always return FALSE.
And I've tried to use the zlib wrapper, which works but makes
non-compressed resources take longer.


Do you want to serve compressed pages via PHP or request compressed
pages to be retrieved from a remote server?

--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Jul 17 '05 #2
Manuel Lemos wrote:

Do you want to serve compressed pages via PHP or request compressed
pages to be retrieved from a remote server?


Request compressed pages. I can find all sorts of documentation and
code examples for the former, but not any about requesting pages. To be
more accurate, I don't know how to decompress the pages. I can request
them with no problem, but the information isn't of use to me in
compressed form.

Jul 17 '05 #3
Keith Bowes <do****@spam.me > wrote:
Request compressed pages. I can find all sorts of documentation and
code examples for the former, but not any about requesting pages. To be
more accurate, I don't know how to decompress the pages. I can request
them with no problem, but the information isn't of use to me in
compressed form.


How do you request the page? HTTP/1.0 or HTTP/1.1? In the later case you
might get a chunked response (tranfser-encoding). See 3.6.1 Chunked
Transfer Coding of rfc 2616.

--

Daniel Tryba

Jul 17 '05 #4
Daniel Tryba wrote:

How do you request the page? HTTP/1.0 or HTTP/1.1? In the later case you
might get a chunked response (tranfser-encoding). See 3.6.1 Chunked
Transfer Coding of rfc 2616.


Yeah, I use HTTP/1.1. I've read the HTTP/1.1 spec, but Chunked Encoding
didn't make sense. I'll try to read it again.

Jul 17 '05 #5
Ok, I might be missing something so please forgive me.

If you are able to have succcess with the zlib library, then you 90%
done, you just need to look at the return header from the server.

your request should look like this (edit as needed)

$hHOST = "www.somedomain .com"; // the domain name for the page
$hURI = "/page_to_get.htm l"; // the page you want
$hREF = "http://mysite.com/was"; // in case you need the referer
$hAGENT = "My fuzzy web bot v1.0"; // the name of the user agent
(browser), IE or Netscape, etc..
$header = "GET $hURI HTTP/1.1" .
. "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, "
. "applicatio n/vnd.ms-powerpoint, application/vnd.ms-excel,
application/msword, "
. .application/x-shockwave-flash, */*\n"
. "Host: $hHOST\n"
. "Referer: $hREF \n"
. "User-Agent: $hAGENT\n"
. "Accept-Encoding: gzip\n"
. "Accept-Language: en-us\n"
. "Connection : Close\n"
. "\n";

now send the $header string to the server after you connect to it,
then look for this line from the server

"Content-Encoding: gzip"

if you find gzip in the encoding header that the server sends back,
then it is sending back encoded data, otherwise it did not encode it.

I hope this help.

Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #6
CountScubula <sc*****@hotmai l.com> wrote:
Ok, I might be missing something so please forgive me. [snip] now send the $header string to the server after you connect to it,
then look for this line from the server

"Content-Encoding: gzip"

if you find gzip in the encoding header that the server sends back,
then it is sending back encoded data, otherwise it did not encode it.


You are missing something indeed. The OP doesn't have problems
requesting compressed files, but _decompressing_ them.

Now if he only posted some sample code with a url to test, we might be
able to help him point to the flaws in his script....

--

Daniel Tryba

Jul 17 '05 #7
Daniel Tryba <ne************ ****@canopus.nl > wrote in message news:<bs******* ***@news.tue.nl >...
CountScubula <sc*****@hotmai l.com> wrote:
Ok, I might be missing something so please forgive me.

[snip]
now send the $header string to the server after you connect to it,
then look for this line from the server

"Content-Encoding: gzip"

if you find gzip in the encoding header that the server sends back,
then it is sending back encoded data, otherwise it did not encode it.


You are missing something indeed. The OP doesn't have problems
requesting compressed files, but _decompressing_ them.

Now if he only posted some sample code with a url to test, we might be
able to help him point to the flaws in his script....

Sounds good to me, :)
I have a small web page that reqest data from server:
http://gzen.myhq.info/serverchk.php

they should try using that link to see if my script can do it?
..... just a thought
Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #8
BTW,

With chunked,

after the header (+ 1 blank line)
you will recieve a number, that number is how many bytes follow
read that many bytes in your buffer, that is the chunk.

then you will recieve another number, that is the next chunk size,
read that many bytes, then repeat

when you recieve 0 as the number, you are done.
Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
8830
by: Dennis Hotson | last post by:
Hi, I'm trying to write a function that adds a file-like-object to a compressed tarfile... eg ".tar.gz" or ".tar.bz2" I've had a look at the tarfile module but the append mode doesn't support compressed tarfiles... :( Any thoughts on what I can do to get around this?
1
1680
by: Ron Clarke | last post by:
Does anyone know how to get the compressed size of a file on disk? FileInfo.Length gives the uncompressed size of a file, but I need to find the amount of disk space taken up by files in compressed directories (Windows XP). Getting the "compressed" attribute is available, but how does one get the compressed size? Thanks in advance. -- Ron Clarke
5
3227
by: PerryG | last post by:
We have a .NET 1.1 client which is sending a gzipped soap request using HttpWebRequest to an Apache server. The Apache server is using a the 'mod_deflate' server to decompress the incoming message, and to also compress the response (GZIP). The mod_deflate filter requires the 'Content-Length' header contained within the incoming request to specify the number of UNCOMPRESSED bytes being sent and not the actual bytes of the body of the...
4
14104
by: Pavel | last post by:
Hello. I am trying to make a folder compressed and failing miserably. Below are three ways that I tried to make it compressed, all of them compile and run w/o any problems, but the folder is still not-compressed. (using NTFS, win2k) // some folder string path = @"C:\TEMP\";
1
1242
by: Charles A. Lackman | last post by:
Hello, I have made an aspx web application that is using Forms Authentication. Each unsecure page has a custom user control on it that will allow the visitor to login and enter secure pages. The question I have is within the Web.Config file. under <authentication mode="Forms"> there is "LOGINURL" because there is not a specific LoginPage I want the user to be redirected back to the requesting page they attempted the logjn from. Is...
1
2620
by: Prabhu | last post by:
Hi. We have an ASP.net Web application in which some of the pages are to be served over secure channel using HTTPS. We have built a framework that allows pages to be served over secure channel specified in a configuration file. When a request for specified pages comes over HTTP, framework detects and redirects the browser over HTTPS. Similarly for non secure pages if the request comes over HTTPS the framework redirects the browser onto...
8
2772
by: robert | last post by:
Hello, I want to put (incrementally) changed/new files from a big file tree "directly,compressed and password-only-encrypted" to a remote backup server incrementally via FTP,SFTP or DAV.... At best within a closed algorithm inside Python without extra shell tools. (The method should work with any protocol which allows somehow read, write & seek to a remote file.) On the server and the transmission line there should never be...
232
13242
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
0
8723
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8602
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.