lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

It was thus said that the Great murali once stated:
> Yes, I have gone through these documents and required help at Socket class
> send and receive functions with POST and GET request sending to third party
> service.
> Here I will provide my request as string please help us providing syntax,
> how to send in Socket's send method and receive the response.
> request:

  Going back to your original post, you gave the following code:

    local payload = [[{"email":""}]]

    local hdrs = {
        [1] = string.format('host: %s:%s', addr,port),
        [2] = 'accept: application/json',
        [3] = 'Content-Type: application/json'

    local req = {
        [1] = 'POST /evl/evIDLookU HTTP/1.1',
        [2] = payload,
        [3] = table.concat(hdrs, '\r\n'),
        [4] = '\r\n'

    req = table.concat(req,  '\r\n')

  Your request is formatted incorrectly.  You have the payload between the
request and the headers, which isn't allowed by the HTTP spec.  You are also
neglecting to set the Content-Length header.  It should be:

	local hdrs = {
	  string.format('Host: %s:%s',addr,port),
	  'Accept: application/json',
	  'Content-Type: application/json',
	  string.format('Content-Length: %d',#payload)

	local res = {
	  'POST /evl/evIDLookU HTTP/1.1',