Giter VIP home page Giter VIP logo

Comments (13)

petersirka avatar petersirka commented on August 23, 2024

Hi @zygis,
this is a fucking situation. I fixed this problem but I think it's not good. Why?

JSON flag should contain application/json content type. I don't know what to do. I left it so.
I'll update partial.js version in few days. Please download source from GitHub.

Thanks.

from framework.

sakateka avatar sakateka commented on August 23, 2024

Route for put and json like this:

framework.route("/api", callback, {flags: ["json", "put"], timeout: 10000}); 

put request header: Content-Type:application/json
and request body: {"key1":"value1","key2":"value2"}

got NULL when doing post request

from framework.

petersirka avatar petersirka commented on August 23, 2024

Hi @sakateka,
thanks ... I fixed it. So:

In new version this works:

framework.route("/api", callback, {flags: ["json"], timeout: 10000});
framework.route("/api", callback, {flags: ["post"], timeout: 10000});
framework.route("/api", callback, {flags: ["json", "put"], timeout: 10000}); 

IMPORTANT: for "json" flag must exist this condition: content-type must be an application/json.
Thanks!

from framework.

zygis avatar zygis commented on August 23, 2024
framework.route("/api", post, {flags: ["post"], timeout: 10000});

request body:

key1=value1&key2=value2

response

Server: nginx/1.5.7
Date: Thu, 02 Jan 2014 09:09:34 GMT
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: partial.js v1311
Cache-Control: private
Vary: Accept-Encoding

400: Bad Request

flags: ["json"] works as expected.

from framework.

petersirka avatar petersirka commented on August 23, 2024

Show me your request headers.
Thanks!

2014/1/2 ®ygimantas [email protected]

framework.route("/api", post, {flags: ["post"], timeout: 10000});

request body:

key1=value1&key2=value2

response

Server: nginx/1.5.7
Date: Thu, 02 Jan 2014 09:09:34 GMT
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: partial.js v1311
Cache-Control: private
Vary: Accept-Encoding

400: Bad Request

flags: ["json"] works as expected.

Reply to this email directly or view it on GitHubhttps://github.com//issues/52#issuecomment-31442663
.

S pozdravom Peter ©irka

Web Site Design s.r.o.

Web Developer
[email protected]
+421 903 163 302

from framework.

zygis avatar zygis commented on August 23, 2024
Accept: */*
Cache-Control: no-cache

I found, that POST is working fine with this header:

Content-Type: application/x-www-form-urlencoded

from framework.

petersirka avatar petersirka commented on August 23, 2024

You can use "raw" flag ... Then you do not use content-type in the request (but you must parse manually body from controller.post).

Thanks.

from framework.

zygis avatar zygis commented on August 23, 2024

But how to use "raw" flag?

framework.route("/api", post, ["raw"]);

I got noting with http method POST

POST http://domain.tld/api
Content-Type: application/x-www-form-urlencoded
key1=value1&key2=value2

 -- response --
0 

from framework.

petersirka avatar petersirka commented on August 23, 2024

I found a bug in "raw" flag. I fixed it.
Really sorry.

from framework.

petersirka avatar petersirka commented on August 23, 2024

I published new version of partial.js. Please update your version and give me a feedback. IMPORTANT: if you want a RAW data then the request must have a content-type !== application/json.

Thanks!

from framework.

zygis avatar zygis commented on August 23, 2024

Not working. Same response.

POST http://domain.tld/api
Content-Type: application/x-www-form-urlencoded
key1=value1&key2=value2

 -- response --
0 

from framework.

petersirka avatar petersirka commented on August 23, 2024

Try to add: "post" flag.
Thanks!

2014/1/2 ®ygimantas [email protected]

Not working. Same response.

POST http://domain.tld/api
Content-Type http://domain.tld/apiContent-Type: application/x-www-form-urlencoded
key1=value1&key2=value2

-- response --
0

Reply to this email directly or view it on GitHubhttps://github.com//issues/52#issuecomment-31462925
.

S pozdravom Peter ©irka

Web Site Design s.r.o.

Web Developer
[email protected]
+421 903 163 302

from framework.

zygis avatar zygis commented on August 23, 2024

Okay, now I understood. This works fine:

function post () {
    // ....
    var postData;
    if (_.isString(self.post)) {
        try {
            //noinspection JSValidateTypes
            postData = JSON.parse(self.post);
        } catch (ignore) {
            try {
                postData = queryString.parse(self.post);
            } catch (ignore) {
                postData = {};
            }
        }
    }
    // ....
}
framework.route("/api", post, {flags: ["raw", "post"], timeout: 10000});

Thank you for help!

from framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.