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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:56:33+00:00 2026-05-27T12:56:33+00:00

When I make a POST request using the following code: string body = Hello

  • 0

When I make a POST request using the following code:

string body = "Hello World";
byte[] bytes = Encoding.ASCII.GetBytes(body);
WebRequest request = WebRequest.Create("http://internalurl");
request.Method = "POST";
request.ContentLength = bytes.Length;

I set the content length to the number of bytes POSTed.
What is the correct ContentLength for a GET request?

  • 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-27T12:56:33+00:00Added an answer on May 27, 2026 at 12:56 pm

    Since you normally doesn’t send any additional data when you do a GET request, the header Content-Length should not be sent at all.

    The header Content-Length should only be included when you are sending a message-body, and the value of the header in question is always the length of this field, measured in (OCTETs) bytes.

    (RFC2616) 14.13 Content-Length

    The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET.

    <snip />

    Applications SHOULD use this field to indicate the transfer-length of the message-body, unless this is prohibited by the rules in section 4.4.


    It’s (AFAIK) considered bad practice to include a message-body when doing a GET request, but when reading the HTTP RFC2616 I see nothing stating that a GET request cannot include a message-body.

    Though I will assume that most web servers today will not reply with what you want them to reply if you send data in a message-body and expects it to be parsed and handled in that case.

    (RFC2616) 4.3 Message Body

    The message-body (if any) of an HTTP message is used to carry the
    entity-body associated with the request or response. The message-body
    differs from the entity-body only when a transfer-coding has been
    applied, as indicated by the Transfer-Encoding header field (section
    14.41).

       message-body = entity-body
                    | <entity-body encoded as per Transfer-Encoding>
    

    Transfer-Encoding MUST be used to indicate any transfer-codings
    applied by an application to ensure safe and proper transfer of the
    message. Transfer-Encoding is a property of the message, not of the entity, and thus MAY be added or removed by any application along the
    request/response chain. (However, section 3.6 places restrictions on
    when certain transfer-codings may be used.)

    The rules for when a message-body is allowed in a message differ for
    requests and responses.

    The presence of a message-body in a request is signaled by the
    inclusion of a Content-Length or Transfer-Encoding header field in the
    request’s message-headers.

    A message-body MUST NOT be included in a request if the specification of the request method (section 5.1.1) does not allow sending an entity-body in requests.

    A server SHOULD read and forward a message-body on any request; if the request method
    does not include defined semantics for an entity-body, then the
    message-body SHOULD be ignored when handling the request.

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

Sidebar

Related Questions

I would like to make POST request using following code <div class=editor-field id=updateDiv >
I'm using the following code to send POST request if validation passes. But it
i am using following code to make an httpPost call but it is returning
I make an ajax request using jquery, this calls the following spring controller: @RequestMapping(value
I'm using clojure-http to make the following POST: (clojure-http.resourcefully/post https://android.apis.google.com/c2dm/send {Authorization (str GoogleLogin auth=
Is it possible to make a POST request from Ruby with open-uri?
I'd like to have one server make an http post request to another server.
I'm working at an app which would make a POST ajax request to a
I am using jQuery to make a POST to a PHP file with the
I'm using jQuery to make an Ajax call using an Http Post in ASP.NET

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.