Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:55:18+00:00 2026-06-11T03:55:18+00:00

I have a file that I make and zip up using the gzip module,

  • 0

I have a file that I make and zip up using the gzip module, the next thing I want to do is send that file into a socket that connects to a web browser. I know I have to change the Http response content-type to application/gzip, but how do I go about actually sending the binary of the gzip so the browser will download it properly?

Here is what I got so far

f_out = gzip.open('downloads.gz', 'wb')
f_in = open('file.txt', 'rb')
f_out.writelines(f_in)
f_in.close()
f_out.close()
#This all works
.....
def make_http_response(self, content, html_type='text/html'):
        response_headers = {
            'Content-Type': html_type+'; encoding=utf8',
            'Content-Length': len(content),
            'Connection': 'close',
        }
        response_headers_string = ''.join('%s: %s\n' % (k, v) for k, v in   response_headers.iteritems())
        response_proto = 'HTTP/1.1'
        if(self.error):
            response_status = '404'
            response_status_text = 'Not Found' 
        else:
            response_status = '200'
            response_status_text = 'OK '
        response = '%s %s %s' %(response_proto, response_status, response_status_text)
        response = response + response_headers_string + '\n' + str(content)
        return response   

I pass in ‘application/gz’ for the html_type field

The problem is what content do I pass in I have a download.gz file in that I just created in the same directory how do I go about sending the binary to the make http response function?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:55:20+00:00Added an answer on June 11, 2026 at 3:55 am

    Simply put the binary raw data of the file in the body of the message, without any kind of modifications.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file that can be any thing like ZIP, RAR, txt, CSV,
I have a file that I want to import into Microsoft Dynamics CRM 2011
I have to make a simple zip file using Visual Studio and VB.NET 2003.
I have bat-file, that make some operations. How to run this file from Delphi
I have an excel file that I need to make some changes. I need
we have some C++ code that we need to create a make file in.
I have a file that contains this <!-- CordovaVersion --> I want to replace
I have a file that I need to parse into an array but I
I have a CDN that is storing media files. Each file I want to
I have a file that I'm using to log IP addresses for a client.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.