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 6541847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:09:17+00:00 2026-05-25T11:09:17+00:00

I’m writing a web service that returns a base64-encoded PDF file, so my plan

  • 0

I’m writing a web service that returns a base64-encoded PDF file, so my plan is to add two headers to the response:

Content-Type: application/pdf
Content-Transfer-Encoding: base64

My question is: Is Content-Transfer-Encoding a valid HTTP header? I think it might only be for MIME. If not, how should I craft my HTTP response to represent the fact that I’m returning a base64-encoded PDF? Thanks.

EDIT:

It looks like HTTP does not support this header. From RFC2616 Section 14:

Note: while the definition of Content-MD5 is exactly the same for HTTP
as in RFC 1864 for MIME entity-bodies, there are several ways in which
the application of Content-MD5 to HTTP entity-bodies differs from its
application to MIME entity-bodies. One is that HTTP, unlike MIME, does
not use Content-Transfer-Encoding
, and does use Transfer-Encoding and
Content-Encoding.

Any ideas for what I should set my headers to? Thanks.

EDIT 2

Many of the code samples found in the comments of this PHP reference manual page seem to suggest that it actually is a valid HTTP header:

http://php.net/manual/en/function.header.php

  • 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-05-25T11:09:17+00:00Added an answer on May 25, 2026 at 11:09 am

    According to RFC 1341 (made obsolete by RFC 2045):

    A Content-Transfer-Encoding header field, which can be used to
    specify an auxiliary encoding that was applied to the data in order to
    allow it to pass through mail transport mechanisms which may have
    data or character set limitations.

    and later:

    Many Content-Types which could usefully be transported via email
    are represented, in their "natural" format, as 8-bit character or
    binary data. Such data cannot be transmitted over some transport
    protocols. For example, RFC 821 restricts mail messages to 7-bit
    US-ASCII data with 1000 character lines.

    It is necessary, therefore, to define a standard mechanism for
    re-encoding such data into a 7-bit short-line format. (…) The
    Content-Transfer-Encoding field is used to indicate the type of
    transformation that has been used in order to represent the body
    in an acceptable manner for transport.

    Since you have a webservice, which has nothing in common with emails, you shouldn’t use this header.

    You can use Content-Encoding header which indicates that transferred data has been compressed (gzip value).

    I think that in your case

    Content-Type: application/pdf
    

    is enough. Additionally, you can set Content-Length header, but in my opinion, if you are building webservice (it’s not http server / proxy server) Content-Type is enough. Please bear in mind that some specific headers (e.g. Transfer-Encoding) if not used appropriately, may cause unexpected communication issues, so if you are not 100% sure about usage of some header – if you really need it or not – just don’t use it.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

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.