调整到老博客的程度
This commit is contained in:
@@ -0,0 +1,740 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr"><head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="robots" content="index, follow" />
|
||||
<link rel="icon shortcut" href="/resources/icon_32x32.png" sizes="32x32" />
|
||||
<link rel="icon" href="/resources/icon_180x180.png" type="image/png" sizes="180x180" />
|
||||
<link rel="apple-touch-icon" href="/resources/icon_180x180.png" sizes="180x180" />
|
||||
<title>Python socket 收取POST协议内容时没有payload – 香风家的火柴盒</title>
|
||||
<meta name="description" content="使用Python搭建简单服务器的时候,只能收到headers,收不到POST内容的情况" /><link rel="canonical" href="https://www.small09.top/posts/230908-py-post/" itemprop="url" />
|
||||
|
||||
<meta property="og:title" content="Python socket 收取POST协议内容时没有payload">
|
||||
<meta
|
||||
property="og:description"
|
||||
content="
|
||||
|
||||
使用Python搭建简单服务器的时候,只能收到headers,收不到POST内容的情况
|
||||
|
||||
">
|
||||
<meta
|
||||
property="og:type"
|
||||
content="
|
||||
article
|
||||
">
|
||||
<meta property="og:url" content="https://www.small09.top/posts/230908-py-post/"><meta property="article:section" content="posts">
|
||||
|
||||
<meta
|
||||
property="article:published_time"
|
||||
content="2023-09-08T00:00:00+08:00">
|
||||
|
||||
|
||||
<meta
|
||||
property="article:modified_time"
|
||||
content="2024-01-04T00:00:00+08:00">
|
||||
|
||||
|
||||
|
||||
<meta itemprop="name" content="Python socket 收取POST协议内容时没有payload">
|
||||
<meta itemprop="description" content="使用Python搭建简单服务器的时候,只能收到headers,收不到POST内容的情况">
|
||||
<meta itemprop="datePublished" content="2023-09-08T00:00:00+08:00">
|
||||
<meta itemprop="dateModified" content="2024-01-04T00:00:00+08:00">
|
||||
<meta itemprop="wordCount" content="204">
|
||||
<meta itemprop="keywords" content="Python,Http,Server">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="Python socket 收取POST协议内容时没有payload">
|
||||
<meta name="twitter:description" content="使用Python搭建简单服务器的时候,只能收到headers,收不到POST内容的情况">
|
||||
|
||||
<link rel="preload" href="/css/compiled/main.min.dd0a2e06153504ce1622d60dbc1c29c348f59a33b1a7ebefabee95a192584553.css" as="style" integrity="sha256-3QouBhU1BM4WItYNvBwpw0j1mjOxp+vvq+6VoZJYRVM=" />
|
||||
<link href="/css/compiled/main.min.dd0a2e06153504ce1622d60dbc1c29c348f59a33b1a7ebefabee95a192584553.css" rel="stylesheet" integrity="sha256-3QouBhU1BM4WItYNvBwpw0j1mjOxp+vvq+6VoZJYRVM=" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="/js/main-head.min.94da6f95b126542222dab3a6e07ffefe1aaf63ec3ca555e827b58b80e7d3f0b7.js" integrity="sha256-lNpvlbEmVCIi2rOm4H/+/hqvY+w8pVXoJ7WLgOfT8Lc="></script>
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/css/custom.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a href="#content" class="hx:sr-only hx:focus-visible:not-sr-only hx:focus-visible:fixed hx:focus-visible:z-50 hx:focus-visible:top-2 hx:focus-visible:left-2 hx:focus-visible:bg-primary-500 hx:focus-visible:text-white hx:focus-visible:px-4 hx:focus-visible:py-2 hx:focus-visible:rounded-md hx:focus-visible:text-sm hx:focus-visible:font-medium">跳至内容</a><div id="hextra-nav-wrapper" class="hextra-nav-container hx:sticky hx:top-0 hx:z-20 hx:w-full hx:bg-transparent hx:print:hidden" style="transition:transform 0.3s ease">
|
||||
<div
|
||||
class="hextra-nav-container-blur hx:pointer-events-none hx:absolute hx:z-[-1] hx:h-full hx:w-full hx:bg-white hx:dark:bg-dark hx:shadow-[0_2px_4px_rgba(0,0,0,.02),0_1px_0_rgba(0,0,0,.06)] hx:contrast-more:shadow-[0_0_0_1px_#000] hx:dark:shadow-[0_-1px_0_rgba(255,255,255,.1)_inset] hx:contrast-more:dark:shadow-[0_0_0_1px_#fff]"
|
||||
></div>
|
||||
|
||||
<nav class="hextra-max-navbar-width hx:mx-auto hx:flex hx:items-center hx:justify-end hx:gap-1 hx:md:gap-2 hx:h-[var(--hextra-navbar-height)] hx:px-6">
|
||||
<a class="hx:flex hx:items-center hx:hover:opacity-75 hx:ltr:mr-auto hx:rtl:ml-auto" href="/">
|
||||
<img class="hx:mr-2 hx:block hx:dark:hidden" src="/resources/icon_180x180.png" alt="Logo" height="40" width="40" />
|
||||
<img class="hx:mr-2 hx:hidden hx:dark:block" src="/resources/icon_180x180.png" alt="Dark Logo" height="40" width="40" />
|
||||
<span class="hx:mr-2 hx:font-extrabold hx:inline hx:select-none">香风家的火柴盒</span>
|
||||
</a>
|
||||
<div style="flex-grow:1"></div>
|
||||
<div class="hx:flex hx:items-center hx:text-sm hx:text-gray-500 hx:dark:text-gray-400" style="gap:1.25rem;padding-right:0.5rem;padding-top:0.5rem;padding-bottom:0.5rem"><a
|
||||
href="/posts"
|
||||
class="hx:whitespace-nowrap hx:hover:text-gray-900 hx:dark:hover:text-gray-100 hx:transition-colors"
|
||||
|
||||
>Blog</a><a
|
||||
href="/daily"
|
||||
class="hx:whitespace-nowrap hx:hover:text-gray-900 hx:dark:hover:text-gray-100 hx:transition-colors"
|
||||
|
||||
>Daily</a><a
|
||||
href="/photograph"
|
||||
class="hx:whitespace-nowrap hx:hover:text-gray-900 hx:dark:hover:text-gray-100 hx:transition-colors"
|
||||
|
||||
>Photograph</a></div><button type="button" aria-label="菜单" aria-expanded="false" class="hextra-hamburger-menu hx:cursor-pointer hx:-mr-1 hx:rounded-sm hx:p-1 hx:active:bg-gray-400/20 hx:md:hidden hx:hextra-focus-visible-inset"><svg height=24 fill="none" viewBox="0 0 24 24" stroke="currentColor"><g><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8H20"></path></g><g><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16H20"></path></g></svg></button>
|
||||
</nav>
|
||||
</div>
|
||||
<script>
|
||||
(function(){
|
||||
var nav = document.getElementById('hextra-nav-wrapper');
|
||||
if(!nav) return;
|
||||
var lastScroll = 0;
|
||||
var threshold = 10;
|
||||
window.addEventListener('scroll', function(){
|
||||
var st = window.pageYOffset || document.documentElement.scrollTop;
|
||||
if(st <= 0){ nav.style.transform = 'translateY(0)'; return; }
|
||||
if(Math.abs(st - lastScroll) < threshold) return;
|
||||
if(st > lastScroll && st > 300){
|
||||
nav.style.transform = 'translateY(-100%)';
|
||||
} else {
|
||||
nav.style.transform = 'translateY(0)';
|
||||
}
|
||||
lastScroll = st;
|
||||
}, {passive:true});
|
||||
})();
|
||||
</script>
|
||||
|
||||
<div class="hx:mx-auto hx:flex hextra-max-page-width">
|
||||
<aside class="hextra-sidebar-container hx:flex hx:flex-col hx:print:hidden hx:md:top-16 hx:md:shrink-0 hx:md:w-64 hx:md:self-start hx:max-md:[transform:translate3d(0,-100%,0)] hx:md:hidden hx:xl:block">
|
||||
<div class="hx:px-4 hx:pt-4 hx:md:hidden">
|
||||
<div class="hextra-search-wrapper hx:relative hx:md:w-64">
|
||||
<div class="hx:relative hx:flex hx:items-center hx:text-gray-900 hx:contrast-more:text-gray-800 hx:dark:text-gray-300 hx:contrast-more:dark:text-gray-300">
|
||||
<input
|
||||
placeholder="搜索文档..."
|
||||
aria-label="搜索文档..."
|
||||
class="hextra-search-input hx:hextra-focus-visible hx:block hx:w-full hx:appearance-none hx:rounded-lg hx:px-3 hx:py-2 hx:transition-colors hx:text-base hx:leading-tight hx:md:text-sm hx:bg-black/[.05] hx:dark:bg-gray-50/10 hx:focus-visible:bg-white hx:dark:focus-visible:bg-dark hx:placeholder:text-gray-500 hx:dark:placeholder:text-gray-400 hx:contrast-more:border hx:contrast-more:border-current"
|
||||
type="search"
|
||||
autocomplete="off"
|
||||
value=""
|
||||
spellcheck="false"
|
||||
/>
|
||||
<kbd
|
||||
class="hx:absolute hx:my-1.5 hx:select-none hx:ltr:right-1.5 hx:rtl:left-1.5 hx:h-5 hx:rounded-sm hx:bg-white hx:px-1.5 hx:font-mono hx:text-[10px] hx:font-medium hx:text-gray-500 hx:border hx:border-gray-200 hx:dark:border-gray-100/20 hx:dark:bg-dark/50 hx:contrast-more:border-current hx:contrast-more:text-current hx:contrast-more:dark:border-current hx:items-center hx:gap-1 hx:transition-opacity hx:pointer-events-none hx:hidden hx:sm:flex"
|
||||
>
|
||||
CTRL K
|
||||
</kbd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<ul
|
||||
class="hextra-search-results hextra-scrollbar hx:hidden hx:border hx:border-gray-200 hx:bg-white hx:text-gray-100 hx:dark:border-neutral-800 hx:dark:bg-neutral-900 hx:absolute hx:top-full hx:z-20 hx:mt-2 hx:overflow-auto hx:overscroll-contain hx:rounded-xl hx:py-2.5 hx:shadow-xl hx:max-h-[min(calc(50vh-11rem-env(safe-area-inset-bottom)),400px)] hx:md:max-h-[min(calc(100vh-5rem-env(safe-area-inset-bottom)),400px)] hx:inset-x-0 hx:ltr:md:left-auto hx:rtl:md:right-auto hx:contrast-more:border hx:contrast-more:border-gray-900 hx:contrast-more:dark:border-gray-50 hx:w-screen hx:min-h-[100px] hx:max-w-[min(calc(100vw-2rem),calc(100%+20rem))]"
|
||||
aria-label="搜索结果"
|
||||
style="transition: max-height 0.2s ease 0s;"
|
||||
></ul>
|
||||
<div class="hextra-search-status hx:sr-only" aria-live="polite" role="status"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><div class="hextra-scrollbar hx:overflow-y-auto hx:overflow-x-hidden hx:p-4 hx:grow hx:md:h-[calc(100vh-var(--navbar-height)-var(--menu-height))]">
|
||||
<ul class="hx:flex hx:flex-col hx:gap-1 hx:md:hidden">
|
||||
|
||||
|
||||
<li class="open"><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:ltr:pr-8 hx:rtl:pl-8 hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Posts</span>
|
||||
</a>
|
||||
<button type="button" class="hextra-sidebar-collapsible-button hx:absolute hx:top-1/2 hx:-translate-y-1/2 hx:ltr:right-2 hx:rtl:left-2 hx:shrink-0 hx:cursor-pointer hx:p-0 hx:text-gray-500 hx:dark:text-neutral-400 hx:group-hover:text-gray-900 hx:dark:group-hover:text-gray-50 hx:group-data-[active=true]:text-primary-800 hx:group-data-[active=true]:dark:text-primary-600 hx:hextra-focus-visible-inset" aria-label="切换章节" aria-expanded="true"><svg fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true" focusable="false" class="hx:h-[18px] hx:min-w-[18px] hx:rounded-xs hx:p-0.5 hx:hover:bg-gray-800/5 hx:dark:hover:bg-gray-100/5"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" class="hx:origin-center hx:transition-transform hx:rtl:-rotate-180"></path></svg></button>
|
||||
</div><div class="hextra-sidebar-children hx:ltr:pr-0 hx:rtl:pl-0 hx:overflow-hidden">
|
||||
<ul class='hx:relative hx:flex hx:flex-col hx:gap-1 hx:before:absolute hx:before:inset-y-1 hx:before:w-px hx:before:bg-gray-200 hx:before:content-[""] hx:ltr:ml-3 hx:ltr:pl-3 hx:ltr:before:left-0 hx:rtl:mr-3 hx:rtl:pr-3 hx:rtl:before:right-0 hx:dark:before:bg-neutral-800'><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/231225-dockernote/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">docker简单笔记</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/231127-vncserver/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Linux安装VNC服务端</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col open"><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="true">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hextra-sidebar-active-item hx:bg-primary-100 hx:font-semibold hx:text-primary-800 hx:contrast-more:border hx:contrast-more:border-primary-500 hx:dark:bg-primary-400/10 hx:dark:text-primary-600 hx:contrast-more:dark:border-primary-500"
|
||||
href="/posts/230908-py-post/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Python socket 收取POST协议内容时没有payload</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/230508-remake-deb/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">讨论在Debian系操作系统中重新提取已安装的软件并重新打包</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/220714-unpackclonezillaimage/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">从再生龙(clonezilla)镜像直接提取文件</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/220223-deepin_partsinddefilemanager/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Deepin/UOS文件管理器隐藏不需要的盘符</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/220104-diylinuxiso/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">定制自己的Linux ISO镜像</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/211203-linuxchangeusername/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">在Linux环境下修改用户名和主目录</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/211115-fixnasdriver/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">记一次拯救NAS硬盘</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/211019-dpkg_package_guide/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">DEB打包方法简介</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210928-rpm_package/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">RPM安装包制作方法</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210914-mdadm/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Linux恢复操作系统后mdadm导致开机变慢的方法</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210914-linuxbackupdd/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">使用dd指令备份和恢复Linux系统(硬盘级)</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210824-linuxtouchscreenfin/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Linux处理多触屏的终极解决方案</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210719-gpuinfoinlinux/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Linux中获得AMD显卡的状态信息</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210630-sudowithoutpasswd/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">免密码使用sudo</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210429-deepinautorun/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">deepin和UOS,快捷方式,开机自启动</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210420-linuxmorethan4serialport/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Linux启用四个以上的串口</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210328-linuxchangemacip/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Linux修改mac地址</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/about_hugo_website/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">关于使用HUGO建立博客站点</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210311-serialmodeandudevinlinux/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Linux串口和udev理解</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210311-multitouchscreeninlinux/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Linux多显示器触屏调试与暂行解决方案</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li><li class="hx:flex hx:flex-col "><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/posts/210218-teamspeakwithdocker/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">使用Docker安装TeamSpeak</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</li></ul>
|
||||
</div></li>
|
||||
<li class=""><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/about-card/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">Kushidou</span>
|
||||
</a>
|
||||
</div></li>
|
||||
<li class=""><div class="hextra-sidebar-item hx:group hx:relative hx:flex hx:items-center" data-active="false">
|
||||
<a
|
||||
class="hx:flex hx:items-center hx:justify-between hx:gap-2 hx:grow hx:cursor-pointer hx:rounded-sm hx:px-2 hx:py-1.5 hx:text-sm hx:transition-colors [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] hx:hextra-focus-visible-inset hx:text-gray-500 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:contrast-more:border hx:contrast-more:border-transparent hx:contrast-more:text-gray-900 hx:contrast-more:hover:border-gray-900 hx:dark:text-neutral-400 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:contrast-more:dark:text-gray-50 hx:contrast-more:dark:hover:border-gray-50"
|
||||
href="/about/"
|
||||
|
||||
>
|
||||
<span class="hx:min-w-0 [word-break:break-word]">关于我</span>
|
||||
</a>
|
||||
</div></li>
|
||||
</ul>
|
||||
|
||||
<div class="hx:max-xl:hidden hx:h-0 hx:w-64 hx:shrink-0"></div></div>
|
||||
|
||||
|
||||
<div class="hx:md:hidden hx:sticky hx:bottom-0 hx:max-h-(--menu-height) hx:bg-white hx:dark:bg-dark hx:mx-4 hx:py-4 hx:shadow-[0_-12px_16px_#fff] hx:flex hx:items-center hx:gap-2 hx:border-gray-200 hx:dark:border-neutral-800 hx:dark:shadow-[0_-12px_16px_#111] hx:contrast-more:border-neutral-400 hx:contrast-more:shadow-none hx:contrast-more:dark:shadow-none hx:border-t" data-toggle-animation="show"><div class="hx:flex hx:grow hx:flex-col"><div class="hx:flex hx:justify-items-start hx:group" data-theme="light">
|
||||
<button
|
||||
title="切换主题"
|
||||
data-state="closed"
|
||||
data-location="bottom"
|
||||
class="hextra-theme-toggle hx:cursor-pointer hx:rounded-md hx:text-left hx:font-medium hx:h-7 hx:px-2 hx:text-xs hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:font-medium hx:text-gray-600 hx:transition-colors hx:dark:text-gray-400 hx:grow"
|
||||
type="button"
|
||||
aria-label="切换主题"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="menu"
|
||||
>
|
||||
<div class="hx:flex hx:items-center hx:gap-2 hx:capitalize"><svg height=12 class="hx:group-data-[theme=dark]:hidden hx:group-data-[theme=system]:hidden" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/></svg><span class="hx:group-data-[theme=dark]:hidden hx:group-data-[theme=system]:hidden">浅色</span><svg height=12 class="hx:group-data-[theme=light]:hidden hx:group-data-[theme=system]:hidden" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/></svg><span class="hx:group-data-[theme=light]:hidden hx:group-data-[theme=system]:hidden">深色</span><svg height=12 class="hx:group-data-[theme=dark]:hidden hx:group-data-[theme=light]:hidden" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M 11.996094,2 C 6.4986225,2.0192368 2.03125,6.5024993 2.03125,12 c 0,5.497501 4.4673725,9.980763 9.964844,10 H 12 12.0039 c 5.497471,-0.01924 9.964844,-4.502499 9.964844,-10 0,-5.4975007 -4.467373,-9.9807632 -9.964844,-10 H 12 Z M 12,4 c 4.417218,0.017598 7.96875,3.5822356 7.96875,8 0,4.417764 -3.551532,7.982402 -7.96875,8 z" />
|
||||
</svg>
|
||||
<span class="hx:group-data-[theme=dark]:hidden hx:group-data-[theme=light]:hidden">跟随系统</span></div>
|
||||
</button>
|
||||
<ul
|
||||
class="hextra-theme-toggle-options hx:hidden hx:z-20 hx:max-h-64 hx:overflow-auto hx:rounded-lg hx:border hx:border-gray-200 hx:bg-white hx:p-1 hx:text-sm hx:shadow-lg hx:dark:border-neutral-700 hx:dark:bg-neutral-900"
|
||||
style="position: fixed; inset: auto auto 0px 0px; margin: 0px; min-width: 100px;"
|
||||
data-theme="light"
|
||||
role="menu"
|
||||
>
|
||||
<li role="none" class="hx:flex hx:flex-col">
|
||||
<button
|
||||
type="button"
|
||||
role="menuitemradio"
|
||||
aria-checked="true"
|
||||
tabindex="-1"
|
||||
data-item="light"
|
||||
class="hx:text-gray-700 hx:dark:text-gray-300 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:dark:hover:bg-neutral-800 hx:dark:hover:text-gray-100 hx:relative hx:cursor-pointer hx:whitespace-nowrap hx:rounded-sm hx:py-1.5 hx:transition-colors hx:ltr:pl-3 hx:ltr:pr-9 hx:rtl:pr-3 hx:rtl:pl-9 hx:text-left hx:w-full hx:bg-transparent hx:border-0"
|
||||
>
|
||||
浅色
|
||||
<span class="hx:absolute hx:inset-y-0 hx:flex hx:items-center hx:ltr:right-3 hx:rtl:left-3 hx:group-data-[theme=dark]:hidden hx:group-data-[theme=system]:hidden"><svg height=1em width=1em xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/></svg></span>
|
||||
</button>
|
||||
</li>
|
||||
<li role="none" class="hx:flex hx:flex-col">
|
||||
<button
|
||||
type="button"
|
||||
role="menuitemradio"
|
||||
aria-checked="false"
|
||||
tabindex="-1"
|
||||
data-item="dark"
|
||||
class="hx:text-gray-700 hx:dark:text-gray-300 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:dark:hover:bg-neutral-800 hx:dark:hover:text-gray-100 hx:relative hx:cursor-pointer hx:whitespace-nowrap hx:rounded-sm hx:py-1.5 hx:transition-colors hx:ltr:pl-3 hx:ltr:pr-9 hx:rtl:pr-3 hx:rtl:pl-9 hx:text-left hx:w-full hx:bg-transparent hx:border-0"
|
||||
>
|
||||
深色
|
||||
<span class="hx:absolute hx:inset-y-0 hx:flex hx:items-center hx:ltr:right-3 hx:rtl:left-3 hx:group-data-[theme=light]:hidden hx:group-data-[theme=system]:hidden"><svg height=1em width=1em xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/></svg></span>
|
||||
</button>
|
||||
</li>
|
||||
<li role="none" class="hx:flex hx:flex-col">
|
||||
<button
|
||||
type="button"
|
||||
role="menuitemradio"
|
||||
aria-checked="false"
|
||||
tabindex="-1"
|
||||
data-item="system"
|
||||
class="hx:text-gray-700 hx:dark:text-gray-300 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:dark:hover:bg-neutral-800 hx:dark:hover:text-gray-100 hx:relative hx:cursor-pointer hx:whitespace-nowrap hx:rounded-sm hx:py-1.5 hx:transition-colors hx:ltr:pl-3 hx:ltr:pr-9 hx:rtl:pr-3 hx:rtl:pl-9 hx:text-left hx:w-full hx:bg-transparent hx:border-0"
|
||||
>
|
||||
跟随系统
|
||||
<span class="hx:absolute hx:inset-y-0 hx:flex hx:items-center hx:ltr:right-3 hx:rtl:left-3 hx:group-data-[theme=dark]:hidden hx:group-data-[theme=light]:hidden"><svg height=1em width=1em xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/></svg></span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div></div></aside>
|
||||
<nav class="hextra-toc hx:order-last hx:hidden hx:w-64 hx:shrink-0 hx:xl:block hx:print:hidden hx:px-4" aria-label="目录">
|
||||
<div class="hextra-scrollbar hx:sticky hx:top-[var(--hextra-navbar-height)] hx:overflow-y-auto hx:pr-4 hx:pt-6 hx:text-sm [hyphens:auto] hx:max-h-[calc(100vh-var(--hextra-navbar-height)-env(safe-area-inset-bottom))] hx:ltr:-mr-4 hx:rtl:-ml-4">
|
||||
<div class=" hx:sticky hx:bottom-0 hx:flex hx:flex-col hx:items-start hx:gap-3 hx:pb-8 hx:border-gray-200 hx:dark:border-neutral-800 hx:contrast-more:border-t hx:contrast-more:border-neutral-400 hx:contrast-more:shadow-none hx:contrast-more:dark:border-neutral-400">
|
||||
|
||||
<div class="hx:text-xs hx:w-full">
|
||||
<div class="hx:font-semibold hx:text-gray-700 hx:dark:text-gray-300 hx:mb-1.5">标签</div>
|
||||
<div class="hx:flex hx:flex-wrap hx:gap-1.5"><a href="/tags/python/" class="hx:inline-block hx:px-2 hx:py-0.5 hx:rounded hx:bg-gray-100 hx:text-gray-600 hx:dark:bg-neutral-800 hx:dark:text-gray-400 hx:text-xs hx:hover:bg-gray-200 hx:dark:hover:bg-neutral-700 hx:transition-colors">python</a><a href="/tags/http/" class="hx:inline-block hx:px-2 hx:py-0.5 hx:rounded hx:bg-gray-100 hx:text-gray-600 hx:dark:bg-neutral-800 hx:dark:text-gray-400 hx:text-xs hx:hover:bg-gray-200 hx:dark:hover:bg-neutral-700 hx:transition-colors">http</a><a href="/tags/server/" class="hx:inline-block hx:px-2 hx:py-0.5 hx:rounded hx:bg-gray-100 hx:text-gray-600 hx:dark:bg-neutral-800 hx:dark:text-gray-400 hx:text-xs hx:hover:bg-gray-200 hx:dark:hover:bg-neutral-700 hx:transition-colors">server</a></div>
|
||||
</div>
|
||||
<button id="backToTop" tabindex="-1" class="hx:cursor-pointer hx:transition-all hx:duration-75 hx:opacity-0 hx:text-xs hx:font-medium hx:text-gray-500 hx:hover:text-gray-900 hx:dark:text-gray-400 hx:dark:hover:text-gray-100 hx:contrast-more:text-gray-800 hx:contrast-more:dark:text-gray-50">
|
||||
<span>返回顶部</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true" focusable="false" class="hx:inline hx:ltr:ml-1 hx:rtl:mr-1 hx:h-3.5 hx:w-3.5 hx:rounded-full hx:border hx:border-gray-500 hx:hover:border-gray-900 hx:dark:border-gray-400 hx:dark:hover:border-gray-100 hx:contrast-more:border-gray-800 hx:contrast-more:dark:border-gray-50">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
<article class="hx:w-full hx:break-words hx:flex hx:min-h-[calc(100vh-var(--hextra-navbar-height))] hx:min-w-0 hx:justify-center hx:pb-8 hx:pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||
<main id="content" class="hx:w-full hx:min-w-0 hextra-max-content-width hx:px-6 hx:pt-4 hx:md:px-12">
|
||||
|
||||
<div class="hx:mt-1.5 hx:flex hx:items-center hx:gap-1 hx:overflow-hidden hx:text-sm hx:text-gray-500 hx:dark:text-gray-400 hx:contrast-more:text-current">
|
||||
<div class="hx:whitespace-nowrap hx:transition-colors hx:min-w-[24px] hx:overflow-hidden hx:text-ellipsis hx:hover:text-gray-900 hx:dark:hover:text-gray-100">
|
||||
<a href="/posts/" class="hx:inline-block hx:rounded-sm hx:hextra-focus-visible-inset">Posts</a>
|
||||
</div><svg class="hx:w-3.5 hx:shrink-0 hx:rtl:-rotate-180" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"/></svg><div class="hx:whitespace-nowrap hx:transition-colors hx:font-medium hx:text-gray-700 hx:contrast-more:font-bold hx:contrast-more:text-current hx:dark:text-gray-100 hx:contrast-more:dark:text-current">Python socket 收取POST协议内容时没有payload</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="hx:flex hx:flex-col hx:sm:flex-row hx:items-start hx:sm:items-center hx:sm:justify-between hx:gap-4 hx:mt-2">
|
||||
<h1 class="hx:mb-0 hx:text-4xl hx:font-bold hx:tracking-tight hx:text-slate-900 hx:dark:text-slate-100">Python socket 收取POST协议内容时没有payload</h1>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="hx:mt-4 hx:mb-16 hx:text-gray-500 hx:dark:text-gray-400 hx:text-sm hx:flex hx:items-center hx:flex-wrap hx:gap-y-2"><span class="hx:mr-1">2023/09/08</span><span class="hx:mx-1">·</span><a href="/about" class="hx:mx-1 hx:hover:underline">Kushidou</a></div>
|
||||
<div class="content">
|
||||
|
||||
<p>使用Python搭建简单服务器的时候,只能收到headers,收不到POST内容的情况</p>
|
||||
<p>最近做了一个简单的http服务器,用于接收IoT端上传的json格式的日志。</p>
|
||||
<p>服务端使用socket中的方法接收原始数据,再对原始数据单独进行处理,根据报文头部的GET或者POST等方法进行具体的操作。</p>
|
||||
<div class="hextra-code-block hx:relative hx:mt-6 hx:first:mt-0 hx:group/code">
|
||||
|
||||
<div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span>sock <span style="color:#f92672">=</span> socket<span style="color:#f92672">.</span>socket(socket<span style="color:#f92672">.</span>AF_INET, socket<span style="color:#f92672">.</span>SOCK_STREAM)
|
||||
</span></span><span style="display:flex;"><span>sock<span style="color:#f92672">.</span>bind((self<span style="color:#f92672">.</span>host, self<span style="color:#f92672">.</span>port))
|
||||
</span></span><span style="display:flex;"><span>sock<span style="color:#f92672">.</span>listen(<span style="color:#ae81ff">128</span>)
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span>(client, address) <span style="color:#f92672">=</span> self<span style="color:#f92672">.</span>sock<span style="color:#f92672">.</span>accept()
|
||||
</span></span><span style="display:flex;"><span>th <span style="color:#f92672">=</span> Thread(target<span style="color:#f92672">=</span>self<span style="color:#f92672">.</span>accept_request, args<span style="color:#f92672">=</span>(client, address))
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">accept_request</span>(client, address):
|
||||
</span></span><span style="display:flex;"><span> data <span style="color:#f92672">=</span> client_sock<span style="color:#f92672">.</span>recv(<span style="color:#ae81ff">8192</span>)
|
||||
</span></span><span style="display:flex;"><span> req <span style="color:#f92672">=</span> data<span style="color:#f92672">.</span>decode(<span style="color:#e6db74">"utf-8"</span>)
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># 处理数据的具体方法</span>
|
||||
</span></span><span style="display:flex;"><span> response <span style="color:#f92672">=</span> process_response(req, client_addr)
|
||||
</span></span><span style="display:flex;"><span> client_sock<span style="color:#f92672">.</span>send(response)
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># clean up</span>
|
||||
</span></span><span style="display:flex;"><span> client_sock<span style="color:#f92672">.</span>shutdown(<span style="color:#ae81ff">1</span>)
|
||||
</span></span><span style="display:flex;"><span> client_sock<span style="color:#f92672">.</span>close()</span></span></code></pre></div></div><div class="hextra-code-copy-btn-container hx:opacity-0 hx:transition hx:group-hover/code:opacity-100 hx:flex hx:gap-1 hx:absolute hx:m-[11px] hx:right-0 hx:top-0">
|
||||
<button
|
||||
class="hextra-code-copy-btn hx:group/copybtn hx:cursor-pointer hx:transition-all hx:active:opacity-50 hx:bg-primary-700/5 hx:border hx:border-black/5 hx:text-gray-600 hx:hover:text-gray-900 hx:rounded-md hx:p-1.5 hx:dark:bg-primary-300/10 hx:dark:border-white/10 hx:dark:text-gray-400 hx:dark:hover:text-gray-50"
|
||||
title="复制代码"
|
||||
aria-label="复制代码"
|
||||
data-copied-label="已复制!"
|
||||
>
|
||||
<div class="hextra-copy-icon hx:group-[.copied]/copybtn:hidden hx:pointer-events-none hx:h-4 hx:w-4"></div>
|
||||
<div class="hextra-success-icon hx:hidden hx:group-[.copied]/copybtn:block hx:pointer-events-none hx:h-4 hx:w-4"></div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p>上面的代码是大概的处理流程。在这个流程中,我发现处理POST的数据的时候,经常只能收到headers部分,payload部分的数据不管发几次都是空的。而且接收缓冲区已经扩大到了8192字节,headers部分的长度只有200多字节,IoT端上传的payload也不过上百字节,不应该是超出缓冲区的问题。</p>
|
||||
<p><strong>=====2024.01.04更新=======</strong></p>
|
||||
<p>下面的方法突然某一天就失效了,我不清楚是不是python的环境变化导致的。</p>
|
||||
<p>其实用flask接收和处理数据会更加方便快捷:</p>
|
||||
<div class="hextra-code-block hx:relative hx:mt-6 hx:first:mt-0 hx:group/code">
|
||||
|
||||
<div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">from</span> flask <span style="color:#f92672">import</span> Flask, request
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#75715e"># 实例化flask</span>
|
||||
</span></span><span style="display:flex;"><span>app <span style="color:#f92672">=</span> Flask(__name__)
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#75715e"># 接收和处理post的方法</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">@app.route</span>(<span style="color:#e6db74">'/test'</span>, methods<span style="color:#f92672">=</span>[<span style="color:#e6db74">'POST'</span>])
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">recv_file_www</span>():
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># post的传入参数</span>
|
||||
</span></span><span style="display:flex;"><span> print(request<span style="color:#f92672">.</span>args<span style="color:#f92672">.</span>to_dict())
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># post所承载的数据</span>
|
||||
</span></span><span style="display:flex;"><span> print(request<span style="color:#f92672">.</span>data)
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> <span style="color:#e6db74">'OK'</span>
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> __name__ <span style="color:#f92672">==</span> <span style="color:#e6db74">'__main__'</span>:
|
||||
</span></span><span style="display:flex;"><span> app<span style="color:#f92672">.</span>run(port<span style="color:#f92672">=</span><span style="color:#ae81ff">31408</span>, host<span style="color:#f92672">=</span><span style="color:#e6db74">"0.0.0.0"</span>,debug<span style="color:#f92672">=</span><span style="color:#66d9ef">True</span>)</span></span></code></pre></div></div><div class="hextra-code-copy-btn-container hx:opacity-0 hx:transition hx:group-hover/code:opacity-100 hx:flex hx:gap-1 hx:absolute hx:m-[11px] hx:right-0 hx:top-0">
|
||||
<button
|
||||
class="hextra-code-copy-btn hx:group/copybtn hx:cursor-pointer hx:transition-all hx:active:opacity-50 hx:bg-primary-700/5 hx:border hx:border-black/5 hx:text-gray-600 hx:hover:text-gray-900 hx:rounded-md hx:p-1.5 hx:dark:bg-primary-300/10 hx:dark:border-white/10 hx:dark:text-gray-400 hx:dark:hover:text-gray-50"
|
||||
title="复制代码"
|
||||
aria-label="复制代码"
|
||||
data-copied-label="已复制!"
|
||||
>
|
||||
<div class="hextra-copy-icon hx:group-[.copied]/copybtn:hidden hx:pointer-events-none hx:h-4 hx:w-4"></div>
|
||||
<div class="hextra-success-icon hx:hidden hx:group-[.copied]/copybtn:block hx:pointer-events-none hx:h-4 hx:w-4"></div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p>上面就是一个完整的post接收和处理程序了,不需要调试socket,也不需要自己处理ResponseBuilder,最重要的是能保证获取到post数据。</p>
|
||||
<p><strong>======以下是原来的内容==========</strong></p>
|
||||
<p>经过网上搜索与自己尝试,发现socket.recv返回的时候是分段返回的,貌似会按照实际内容切割返回,<strong>必须不断的recv才能完整接收数据</strong>。有一种解决方案是POST传送之前先确定报文的完整擦换个年度,然后利用while循环,接收到对应长度才结束。</p>
|
||||
<p>但是POST发送的一个不定长的数据,如果每次都通过http报文先传送post完整长度的话,有些浪费资源。于是我想到了这么一个方案:</p>
|
||||
<p>POST的报文头会包含一个<code>Content-length</code>的数据,记录的是payload的长度。那我在接收阶段就对headers部分进行解码和处理,获取到content-length后,在加上本次获取headers的长度就是POST的完整长度了。</p>
|
||||
<p>那么将上面代码的<code>client_sock.recv()</code>部分改写成下面的方法:</p>
|
||||
<div class="hextra-code-block hx:relative hx:mt-6 hx:first:mt-0 hx:group/code">
|
||||
|
||||
<div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">recv</span>(self, client_sock):
|
||||
</span></span><span style="display:flex;"><span> lrecved <span style="color:#f92672">=</span> <span style="color:#ae81ff">8192</span> <span style="color:#75715e"># 记录每次接收的长度</span>
|
||||
</span></span><span style="display:flex;"><span> lrecv_all<span style="color:#f92672">=</span><span style="color:#ae81ff">0</span> <span style="color:#75715e"># 记录数据总长度 </span>
|
||||
</span></span><span style="display:flex;"><span> data_body <span style="color:#f92672">=</span> bytes() <span style="color:#75715e"># 接收的所有数据存入这里</span>
|
||||
</span></span><span style="display:flex;"><span> payload_len <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span> <span style="color:#75715e"># 解析的payload长度</span>
|
||||
</span></span><span style="display:flex;"><span> payload_flag <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span> <span style="color:#75715e"># 用于记录是否接收到了payload,以及实时记录接收到payload的长度</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">while</span> <span style="color:#66d9ef">True</span> :
|
||||
</span></span><span style="display:flex;"><span> part_body<span style="color:#f92672">=</span> client_sock<span style="color:#f92672">.</span>recv(<span style="color:#ae81ff">8192</span>) <span style="color:#75715e"># 循环接收数据</span>
|
||||
</span></span><span style="display:flex;"><span> data_body <span style="color:#f92672">+=</span> part_body <span style="color:#75715e"># 将接收的数据写入data_body</span>
|
||||
</span></span><span style="display:flex;"><span> lrecved <span style="color:#f92672">=</span> len(part_body) <span style="color:#75715e"># 获取本次接收长度</span>
|
||||
</span></span><span style="display:flex;"><span> lrecv_all <span style="color:#f92672">+=</span> lrecved <span style="color:#75715e"># 计算总长度</span>
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> payload_flag <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#75715e"># 没有接收到payload部分时,才进入下面的判断流程</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> data_body[<span style="color:#ae81ff">0</span>:<span style="color:#ae81ff">3</span>]<span style="color:#f92672">.</span>decode() <span style="color:#f92672">==</span> <span style="color:#e6db74">'GET'</span>: <span style="color:#75715e"># 由于我get方法没出现过断开的问题,因此直接返回即可。</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">break</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">elif</span> data_body[<span style="color:#ae81ff">0</span>:<span style="color:#ae81ff">4</span>]<span style="color:#f92672">.</span>decode() <span style="color:#f92672">==</span> <span style="color:#e6db74">'POST'</span>:
|
||||
</span></span><span style="display:flex;"><span> payload_len <span style="color:#f92672">=</span> count_payload_len(data_body) <span style="color:#75715e"># 解析头部,计算payload部分的长度</span>
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> lrecved <span style="color:#f92672"><</span> payload_len:
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># 偶尔会出现能接收到payload的情况,所以多加了一个判断。</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># 能接收payload肯定总长度大于payload_len的</span>
|
||||
</span></span><span style="display:flex;"><span> print(<span style="color:#e6db74">"no payloads, keep recving..."</span>)
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># 计算post报文的总长度,借用payload_flag变量</span>
|
||||
</span></span><span style="display:flex;"><span> payload_flag <span style="color:#f92672">=</span> lrecved <span style="color:#f92672">+</span> payload_len
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># 当接收到的总长度 >= POST的计算长度,表示所有数据接收完成,退出</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> payload_flag <span style="color:#f92672"><=</span> lrecv_all:
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">break</span>
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> data_body</span></span></code></pre></div></div><div class="hextra-code-copy-btn-container hx:opacity-0 hx:transition hx:group-hover/code:opacity-100 hx:flex hx:gap-1 hx:absolute hx:m-[11px] hx:right-0 hx:top-0">
|
||||
<button
|
||||
class="hextra-code-copy-btn hx:group/copybtn hx:cursor-pointer hx:transition-all hx:active:opacity-50 hx:bg-primary-700/5 hx:border hx:border-black/5 hx:text-gray-600 hx:hover:text-gray-900 hx:rounded-md hx:p-1.5 hx:dark:bg-primary-300/10 hx:dark:border-white/10 hx:dark:text-gray-400 hx:dark:hover:text-gray-50"
|
||||
title="复制代码"
|
||||
aria-label="复制代码"
|
||||
data-copied-label="已复制!"
|
||||
>
|
||||
<div class="hextra-copy-icon hx:group-[.copied]/copybtn:hidden hx:pointer-events-none hx:h-4 hx:w-4"></div>
|
||||
<div class="hextra-success-icon hx:hidden hx:group-[.copied]/copybtn:block hx:pointer-events-none hx:h-4 hx:w-4"></div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p>里面解析headers的代码如下:</p>
|
||||
<div class="hextra-code-block hx:relative hx:mt-6 hx:first:mt-0 hx:group/code">
|
||||
|
||||
<div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">count_payload_len</span>(data):
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">for</span> d <span style="color:#f92672">in</span> data<span style="color:#f92672">.</span>split(<span style="color:#e6db74">b</span><span style="color:#e6db74">'</span><span style="color:#ae81ff">\r\n</span><span style="color:#e6db74">'</span>): <span style="color:#75715e"># 通过\r\n来分隔报文头</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> <span style="color:#e6db74">"LENGTH"</span> <span style="color:#f92672">in</span> d<span style="color:#f92672">.</span>upper()<span style="color:#f92672">.</span>decode(): <span style="color:#75715e"># 如果报文头部有length关键词,当然可以写完整,我的heasers没有其他的length就简化了</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> int(d<span style="color:#f92672">.</span>decode()<span style="color:#f92672">.</span>split(<span style="color:#e6db74">":"</span>)[<span style="color:#ae81ff">1</span>]) <span style="color:#75715e"># 分隔出payload长度并返回</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> <span style="color:#ae81ff">0</span></span></span></code></pre></div></div><div class="hextra-code-copy-btn-container hx:opacity-0 hx:transition hx:group-hover/code:opacity-100 hx:flex hx:gap-1 hx:absolute hx:m-[11px] hx:right-0 hx:top-0">
|
||||
<button
|
||||
class="hextra-code-copy-btn hx:group/copybtn hx:cursor-pointer hx:transition-all hx:active:opacity-50 hx:bg-primary-700/5 hx:border hx:border-black/5 hx:text-gray-600 hx:hover:text-gray-900 hx:rounded-md hx:p-1.5 hx:dark:bg-primary-300/10 hx:dark:border-white/10 hx:dark:text-gray-400 hx:dark:hover:text-gray-50"
|
||||
title="复制代码"
|
||||
aria-label="复制代码"
|
||||
data-copied-label="已复制!"
|
||||
>
|
||||
<div class="hextra-copy-icon hx:group-[.copied]/copybtn:hidden hx:pointer-events-none hx:h-4 hx:w-4"></div>
|
||||
<div class="hextra-success-icon hx:hidden hx:group-[.copied]/copybtn:block hx:pointer-events-none hx:h-4 hx:w-4"></div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p>上面的代码其实写的很复杂,因为我解析POST整体报文的功能已经写完并且通过第三方http报文调试工具验证过了,上IoT设备实验的时候才发现了问题,本着少改一点是一点的原则,就把这一部分复杂化了,但确实解决了我的问题,就OK了。</p>
|
||||
<p>对了,这篇博客就是利用这个这个方案改造的新服务端进行上传同步的,之前用GitHub Actions进行同步博客,每次运营商都会发一条高危访问的短信和邮件通知我,太烦了。</p>
|
||||
</div>
|
||||
<div class="hx:mt-12 hx:mb-8 hx:block hx:text-xs hx:text-gray-500 hx:ltr:text-right hx:rtl:text-left hx:dark:text-gray-400">
|
||||
最后更新于 <time datetime="2024-01-04T00:00:00.000Z">2024/01/04</time></div><div class="hx:mb-8 hx:flex hx:items-center hx:border-t hx:pt-8 hx:border-gray-200 hx:dark:border-neutral-800 hx:contrast-more:border-neutral-400 hx:dark:contrast-more:border-neutral-400 hx:print:hidden"><a
|
||||
href="/posts/230508-remake-deb/"
|
||||
title="讨论在Debian系操作系统中重新提取已安装的软件并重新打包"
|
||||
class="hx:flex hx:max-w-[50%] hx:items-center hx:gap-1 hx:py-4 hx:text-base hx:font-medium hx:text-gray-600 hx:transition-colors [word-break:break-word] hx:hover:text-primary-600 hx:dark:text-gray-300 hx:md:text-lg hx:ltr:pr-4 hx:rtl:pl-4"
|
||||
><svg class="hx:inline hx:h-5 hx:shrink-0 hx:ltr:rotate-180" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"/></svg>讨论在Debian系操作系统中重新提取已安装的软件并重新打包</a><a
|
||||
href="/posts/231127-vncserver/"
|
||||
title="Linux安装VNC服务端"
|
||||
class="hx:flex hx:max-w-[50%] hx:items-center hx:gap-1 hx:py-4 hx:text-base hx:font-medium hx:text-gray-600 hx:transition-colors [word-break:break-word] hx:hover:text-primary-600 hx:dark:text-gray-300 hx:md:text-lg hx:ltr:ml-auto hx:ltr:pl-4 hx:ltr:text-right hx:rtl:mr-auto hx:rtl:pr-4 hx:rtl:text-left"
|
||||
>Linux安装VNC服务端<svg class="hx:inline hx:h-5 hx:shrink-0 hx:rtl:-rotate-180" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"/></svg></a></div>
|
||||
|
||||
<div id="remark42"></div>
|
||||
<script>
|
||||
var remark42_config = {
|
||||
host: 'https:\/\/www.small09.top\/comment',
|
||||
site_id: 'blog',
|
||||
max_shown_comments: 15,
|
||||
theme: 'light',
|
||||
page_title: 'Python socket 收取POST协议内容时没有payload',
|
||||
locale: 'en',
|
||||
};
|
||||
</script>
|
||||
<script src="https://www.small09.top/comment/web/embed.js"></script>
|
||||
<script>
|
||||
(function () {
|
||||
function getRemark42Theme() {
|
||||
var stored = localStorage.getItem('color-theme');
|
||||
if (stored === 'light' || stored === 'dark') return stored;
|
||||
if (stored === 'system') {
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
var defaultTheme = '';
|
||||
if (defaultTheme === 'light' || defaultTheme === 'dark') return defaultTheme;
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
|
||||
function setRemark42Theme() {
|
||||
var frame = document.querySelector('iframe#remark42-frame');
|
||||
if (frame && frame.contentWindow) {
|
||||
frame.contentWindow.postMessage(
|
||||
{ theme: getRemark42Theme() },
|
||||
remark42_config.host
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
remark42_config.theme = getRemark42Theme();
|
||||
|
||||
window.addEventListener('message', function (e) {
|
||||
if (e.data && e.data.remark42) {
|
||||
setRemark42Theme();
|
||||
}
|
||||
});
|
||||
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', setRemark42Theme);
|
||||
|
||||
var toggles = document.querySelectorAll('.hextra-theme-toggle-options [data-item]');
|
||||
if (toggles) {
|
||||
toggles.forEach(function (toggle) {
|
||||
toggle.addEventListener('click', function () {
|
||||
setTimeout(setRemark42Theme, 200);
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</main>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<footer class="hextra-footer hx:bg-gray-100 hx:pb-[env(safe-area-inset-bottom)] hx:dark:bg-neutral-900 hx:print:bg-transparent">
|
||||
<div class="hextra-max-footer-width hx:mx-auto hx:flex hx:justify-center hx:text-gray-500 hx:dark:text-gray-400 hx:text-xs" style="padding:24px 16px">
|
||||
<div style="text-align:center;line-height:1.8">
|
||||
<div>
|
||||
2021-2026 © Kushidou ·
|
||||
Powered by <a href="https://github.com/imfing/hextra" target="_blank" rel="noreferrer" style="text-decoration:none" class="hx:hover:text-gray-700 hx:dark:hover:text-gray-200">Hextra</a> and
|
||||
<a href="https://gohugo.io/" target="_blank" rel="noreferrer" style="text-decoration:none" class="hx:hover:text-gray-700 hx:dark:hover:text-gray-200">Hugo</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="https://beian.miit.gov.cn/" target="_blank" rel="noreferrer" style="text-decoration:none" class="hx:hover:text-gray-700 hx:dark:hover:text-gray-200">苏ICP备2021006778号</a>
|
||||
  
|
||||
<a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=32040502000157" target="_blank" rel="noreferrer" style="text-decoration:none" class="hx:hover:text-gray-700 hx:dark:hover:text-gray-200">苏公网安备 32040502000157号</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
||||
<script defer src="/js/main.min.d9fbefbbac8caeb66025dbb14d569c30defac0effcba45486a78209fba9360af.js" integrity="sha256-2fvvu6yMrrZgJduxTVacMN76wO/8ukVIanggn7qTYK8="></script>
|
||||
<script defer src="/js/flexsearch.433e941a8a573ebb9931fc16fc75266ab6b93f569ac2fb4f3dc66882e0416f4c.js" integrity="sha256-Qz6UGopXPruZMfwW/HUmara5P1aawvtPPcZoguBBb0w=" crossorigin="anonymous"></script><script defer src="/en.search.min.2cc417b6975b6621e049223d9f505ea2e6bd026e4cae8052a858eafc78cf230e.js" integrity="sha256-LMQXtpdbZiHgSSI9n1Beoua9Am5MroBSqFjq/HjPIw4="></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user