Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection::post() seems to send deformed data #181

Open
NateNate60 opened this issue Jul 25, 2022 · 0 comments
Open

Connection::post() seems to send deformed data #181

NateNate60 opened this issue Jul 25, 2022 · 0 comments

Comments

@NateNate60
Copy link

Expected behaviour

I was experiencing some issues authenticating with the Reddit API using this client, so I tried to isolate the problem in a blank C++ file, and I believe it is because the library is sending deformed data to the server.

I have a simple test.cpp with the following contents:

#include <restclient-cpp/restclient.h>
#include <restclient-cpp/connection.h>

int main () {
    RestClient::init();
    RestClient::Connection * connection = new RestClient::Connection ("http://localhost:3000");
    RestClient::Response response = connection->post("/post", "{\"foo\": \"bar\"}");
    delete connection;
    RestClient::disable();
}

...and I spun up a simple web server in Express.js that just repeats back what it receives with the following contents:

'use strict';
const PORT = 3000;
const express = require("express");
const app = express();
app.use(express.static('public'));
app.use(express.urlencoded({
    extended: true
}));

app.post("/post", (req, res) => {
    console.log(req.body)
    res.send({})
})

app.listen(PORT, () => {
    console.log(`Server listening on port ${PORT}...`);
});

I expected the Express server to print this:

Server listening on port 3000...
{ foo: 'bar' }

...which was generated by sending the following request with Python requests:

requests.post("http://localhost:3000/post", {"foo": "bar"})

Actual behaviour

Server listening on port 3000...
{ '{"foo": "bar"}': '' }

Environment and debugging details

  • compiler and version: g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0
  • operating system: Ubuntu 22.04 LTS amd64
  • version of restclient-cpp: master
  • how did you install restclient-cpp? (via packages, git, tarball): git
  • libcurl version and compile flags: libcurl4-openssl-dev/jammy-updates,jammy-security,now 7.81.0-1ubuntu1.3 amd64

(some of these things might not apply but the more you can provide the easier
it will be to fix this bug. Thanks!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant