Node.js HTTP Get URL Length limitation

前端 未结 2 1981
情深已故
情深已故 2021-01-03 22:07

Is there a limit to the size when making HTTP GET requests in Node.js? And if so, how can I change this?

var url = \"...\" // very long, ~50\'000 chars
http.         


        
2条回答
  •  没有蜡笔的小新
    2021-01-03 22:50

    There is a built-in request size limit enforced by Node. Requested headers + URI should not be more than 80 kb.

    As it is defined in http_parser.h#L55:

    /* Maximium header size allowed */
    #define HTTP_MAX_HEADER_SIZE (80*1024)
    

    Asuming that UTF-8 character can be between 1 and 4 bytes, the size of a string with 50 000 characters would be from 50 000 to 200 000 bytes, or from ~48kb to 195kb.

提交回复
热议问题