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

Request string reprenetations prints non-existing field #193

Open
DifferentialOrange opened this issue Sep 18, 2023 · 0 comments
Open

Request string reprenetations prints non-existing field #193

DifferentialOrange opened this issue Sep 18, 2023 · 0 comments
Labels
bug Something isn't working question Further information is requested

Comments

@DifferentialOrange
Copy link
Member

tostring(req) invokes request_tostring function, which does the following step:

return sprintf("%s\r\n%s", res, self.body)

But request does not have a body attribute. response does. String representation of a request always ends with empty lines since .body == nil.

local log = require('log')

local http_server = require('http.server')

box.cfg{}

local httpd = http_server.new('127.0.0.1', 8081)
httpd:route(
    { path = '/hello', method = 'POST' }, function(req)
        local _ = req:json() -- If removed, result is the same.
        log.info(req.body)
        log.info(tostring(req))
        return req:render{text = 'OK'}
    end)
httpd:start()
curl -X POST localhost:8081/hello?a=a -d '{"sdfs":"dfdfsfs"}'
2023-09-18 10:31:12.506 [1212600] main/114/http/127.0.0.1:60846/http.server I> POST /hello?a=a
2023-09-18 10:31:12.506 [1212600] main/114/http/127.0.0.1:60846/. I> 
2023-09-18 10:31:12.506 [1212600] main/114/http/127.0.0.1:60846/. I> POST /hello?a=a HTTP/1.1
Host: localhost:8081
Content-type: application/x-www-form-urlencoded
Content-length: 18
Accept: */*
User-agent: curl/7.81.0


@DifferentialOrange DifferentialOrange added bug Something isn't working question Further information is requested labels Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant