路由的占位符解析和查询参数的解析覆盖问题
- Lingua principale
- C
- Stelle
- 7.6k
- Fork
- 1.4k
- Merge medio
- 1g 21h
- PR unite (30g)
- 9
Descrizione
router.cpp示例中:
https://github.com/ithewei/libhv/blob/0325f2d07f10986139174ff2db75dd151c09b605/examples/httpd/router.cpp#L131-L134
这里路由占位符的解析是在Handler::restful中调用了HttpContext的param,即HttpRequest的GetParam:
https://github.com/ithewei/libhv/blob/0325f2d07f10986139174ff2db75dd151c09b605/examples/httpd/handler.cpp#L171-L179
这个方法是查询参数的解析,这样合在一起会导致这里占位符的解析覆盖了查询参数的解析,如对于/api/test/{str},会导致 GET http://ip:port/api/test/xxx?str=yyy 后,服务器获取查询参数param("str")时,xxx会覆盖yyy
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Start with the route registration in examples/httpd/router.cpp around lines 131-134, then trace Handler::restful and HttpRequest::GetParam in examples/httpd/handler.cpp around lines 171-179. Reproduce the issue with /api/test/xxx?str=yyy and inspect how the path placeholder and query parameter are resolved. Done means the placeholder no longer overrides the query parameter named str.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp
- Ambito
- api, backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100