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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:17:42+00:00 2026-05-23T03:17:42+00:00

I am currently working with a piece of code that has been written by

  • 0

I am currently working with a piece of code that has been written by somebody else. It uses httplib to make requests to server. It has all the data supplied in a correct format – for example message body, header values, etc.

The problem is that each time it attempts to send a POST requests, the data is there – I can see it on the client side, however nothing arrives to the server. I’ve read through the library specification and the usage seems to be correct.

The extracted library calls go as follows:

import httplib

conn = httplib.HTTPConnection('monkeylabs.pl', 80)
conn.connect()
request = conn.putrequest('POST', '/api/snippet/')
headers = {}
headers['Content-Type'] = 'application/json'
headers['User-Agent'] = 'Envjs/1.618 (SpyderMonkey; U; Linux x86_64 2.6.38-10-generic;  pl_PL.utf8; rv:2.7.1) Resig/20070309 PilotFish/1.3.pre03'
headers['Accept'] = '*/*'
for k in headers:
    conn.putheader(k, headers[k])
conn.endheaders()

conn.send('[{"id":"route"}]')

resp = conn.getresponse()
print resp.status
print resp.reason
print resp.read()

conn.close()

Is this some known issue, or what? I’m using Python 2.7. Not sure how to check the version of httplib.

Please don’t suggest to exchange httplib for something else unless it’s something really similar (httplib2 perhaps). As I said, the code isn’t mine and it comes in much greater amounts than what I’ve just posted above. Refactoring it would cause a major problem. I’m interested in any reliable workarounds.

EDIT

The debug output:

send: 'POST /api/snippet/ HTTP/1.1\r\nHost: monkeylabs.pl\r\nAccept-Encoding: identity\r\nContent-Type: application/json\r\nAccept: */*\r\nUser-Agent: Envjs/1.618 (SpyderMonkey; U; Linux x86_64 2.6.38-10-generic; pl_PL.utf8; rv:2.7.1) Resig/20070309 PilotFish/1.3.pre03\r\n\r\n[{"id":"route"}]'
reply: 'HTTP/1.0 201 CREATED\r\n'
header: Date: Fri, 10 Jun 2011 23:54:00 GMT
header: Server: WSGIServer/0.1 Python/2.7.1+
header: Vary: Cookie
header: Content-Type: application/json
header: Content-Length: 0
201
CREATED

Note that the information after reply actually talks about the server reply, not the request itself, which in this case is empty. The primary cause is that the request body itself is empty which I can observe by getting a log:

[11/Jun/2011 01:54:00] "POST /api/snippet/ HTTP/1.1" 201 0

And those three lines:

``
<QueryDict: {}>
<QueryDict: {}>

out of:

print '`%s`' % request.raw_post_data
print request.GET
print request.POST

on the Django server. So it seems it attempts to send the body but doesn’t send it in the end.

EDIT(2)

Ok, I took a dump and it indeed told me that in the message sent from the browser there is an additional parameter called ‘Content-Length’ which has been omitted in the regular usage of the library. Silly me.

  • 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-23T03:17:42+00:00Added an answer on May 23, 2026 at 3:17 am

    try adding:

    conn.set_debuglevel(1)
    

    to your code so you can see what is actually happening.

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

Sidebar

Related Questions

I am currently working on the maintenance of a piece of code that is
I'm currently working with a piece of code to detect whether a user has
Let's say you are working on a piece of legacy code that was written
I am currently working on a project that is accessing a piece of hardware
I'm working on a project that has a lot of legacy C code. We've
I am currently working a piece of code which needs to send an attachment
Currently I have a piece of code that works fine as long as there
I am currently working on a piece of python code integrated with c++ on
To put the problem simply, I have a piece of code that is currently
In the code I am currently working on I came across a piece code

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.