完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我使用的是传统MLA的HTTP2服务器。我的项目包括简单的CGI来更新配置。通过POST请求发送新的设置,解析,然后保存到Flash。我使用额外的全局变量来存储这个操作的结果。HtpPrimtTyAbcf()函数使用这个变量把它报告给浏览器。我用Ajax使用这个CGI。我好奇一件事:假设在下一个POST请求(例如从另一个浏览器)改变全局变量值之前,HTTP2能够调用HTTPPRIN是可能的吗?TXXXX()函数?还是保证在完成GEP/POST解析后立即调用HtpPress?
以上来自于百度翻译 以下为原文 I am using HTTP2 server from legacy MLA. My project include simple CGI for updating configuration. New settings are sent by POST request, parsed and then saved to flash. I use additional global variable, to store result of this operation. HTTPPrint_abc() function uses this variable to report it back to the browser. I am using this CGI with Ajax. I am curious of one thing: is it hypothetically possible, to change global variable value by the next POST request (for example from another browser) before HTTP2 will be able to call HTTPPrint_xxxx() functions? Or is it guaranteed that HTTPPrint is called right away after finishing GET/POST parsing? |
|
相关推荐
6个回答
|
|
马立克,如果我不理解你的问题——因此我的答案是无用的——我先道歉。为了避免使用全局变量来保存GET/POST和HTTPrPrimTo()调用之间的值,你可以在HTTPrPrdTo()调用中……换句话说,在你的HTTPPRI中完成所有的处理。可以调用TCPIpHeTpJARARGETE()的NTS-()函数,并解析传入参数的HtpDATABuffF缓冲区。我这样做是为了获得请求,(至少看起来)似乎工作得很好…这消除了对全局变量的需求,并使代码重新进入(即,您不必担心同时出现多个GET请求和数据损坏的可能性)。请让我知道。最好的是,文森佐。
以上来自于百度翻译 以下为原文 Marek, If I didn't understand your question -- and therefore my answer is not useful -- I apologize in advance. In order to avoid using global variables to hold values between a GET/POST and an HTTPPrint() call, you can do all your processing in the HTTPPrint() call ... In other words, in your HTTPPrint() function you can call TCPIP_HTTP_ArgGet() and parse the httpDataBuff buffer for incoming arguments. I have done it for GET requests, and (at least apparently) seems to work well ... This eliminates the need for a global variable and makes your code re-entrant (i.e. you don't have to worry about multiple GET requests coming in at the same time and the possibility of data corruption) Let me know. Best, Vincenzo |
|
|
|
像你一样,我也不确定一个新的get /POST是否可以在HypPrPtter()之前调用以前的get / POST。为了确保我已经添加了一个全局数组的工作结构,其中包含了Max的Htppx连接元素。然后在GET/POST和HTTPPRIN()函数中用CURHTTPID进行索引。/ Ruben
以上来自于百度翻译 以下为原文 Like you, I am also not sure if a new GET/POST could come before the HTTPPrint() call for the previous GET/POST. Just to be sure I have added a global array of work structures which have MAX_HTTP_CONNECTIONS elements. These are then indexed with curHTTPID in the GET/POST and HTTPPrint() functions. /Ruben |
|
|
|
我也同意。我认为如果有两个请求同时出现,特别是对于可以是多包的POST数据,这是可能的。我把我的工作数据存储在CurrHTP.DATA请求中,我认为这个目的是因为它是每个套接字,并且还用CurHTTPID索引数组。
以上来自于百度翻译 以下为原文 I also agree. I think it would be possible if two requests come at the same time especially for post data that could be multi packet. I stored my work data for the request in curHTTP.data which I figured was for this purpose as it is per socket and have also indexed an array by curHTTPID. |
|
|
|
这可能是GET请求的一个很好的解决方案,其中一次接收全部信息。但我认为这对于POST请求是行不通的,因为有时需要执行函数几次,因为额外的数据块到达了。现在我使用了简单的解决方案,通过向CURHTTP结构添加另一个变量,用它发送EnUM结果代码来获得Goo/PoST操作以打印乐趣。这个解决方案足够好吗?还是有可能在打印功能之前处理另一个连接的下一个GET/POST请求,重写我的CURHTTP结构?
以上来自于百度翻译 以下为原文 This may be a good solution for GET requests, where entire information is received at once. But I think it wouldn't work for POST requests, because sometimes they need to execute function several times, as additional chunks of data arrive. For now I used simple solution, by adding another variable to curHTTP structure, which I use to send enum result code of GET/POST operation to print function. Is this solution good enough? Or is it possible that next GET/POST request of another connection will be handled before Print function, overwriting my curHTTP structure? |
|
|
|
克里斯/鲁本/马立克,你说得对。它只会(可能)为获取请求工作。我用GET使用了很多网页,我还没有遇到任何问题。我喜欢使用一个全局数组结构,然后使用CurHTTPID和/或使用CurHTTP.DATA索引这些想法。这些解决方案是稳健和优雅的。谢谢您的贡献。最好的,文森佐。
以上来自于百度翻译 以下为原文 Chris / Ruben / Marek, You are correct. It would only (possibly) work for GET requests. I have used it a lot for web pages using GET, and I have not had any problems (yet). I like the idea of using a global array of structures which are then indexed using curHTTPID and/or using curHTTP.data. These solutions are robust and elegant. Thank you for contributing your experience. Best, Vincenzo |
|
|
|
可以将CurHTTP视为会话变量。当CurHTTP.SMSPoST为零时,我需要进行任何初始化,这是调用HtpPtMyMyType()时的第一个状态。为了达到我的目的,我确实增加了CurHTTPDATA [ HTTPXMAXDATAYLLEN ]的大小。
以上来自于百度翻译 以下为原文 You can think of the curHTTP as the session variable. I do any initialiasation that i need when curHTTP.smPost is zero - the first state when HTTPPostMyFunction() is called. I did increase the size of curHTTP.data [HTTP_MAX_DATA_LEN] for my purpose. |
|
|
|
只有小组成员才能发言,加入小组>>
5234 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3201 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
771浏览 1评论
659浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
588浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
670浏览 0评论
571浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 11:46 , Processed in 2.044803 second(s), Total 88, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号