Ask the regular heroes to help

Source: Internet
Author: User
Tags cdata nets
http/1.1 Okserver:nginx/0.7.68date:sat, 07:44:57 gmtcontent-type:application/rss+xml; Charset=utf-8transfer-encoding:chunkedconnection:keep-alive3ab4
 
  
   
   <title>CSDN Mobile Channel (info)</title> 
   
    
   Http://mobile.csdn.net 
   
    
     Open Platform
    
    
   
    
     Sat, Geneva 15:44:50
    
    
   
    
 
     Mobile Weekly: Why did I abandon objective-c and choose rubymotion?
 
      
     
      Http://www.csdn.net/article/2013-03-01/2814309-mobile-weekly-choose-rubymotion-for-ios-dev 我们为您精心准备了CSDN移动频道本周最精彩的热点新闻,开发者直言RubyMotion优与劣,讲述为何弃用Objective-C而选择RubyMotion;出生贫苦的Minecraft开发者Notch大神特立独行,始终秉承开放的游戏开发理念;移动互联网大潮来袭,国家级老牌媒体China Daily将怎样拥抱新媒体时代? 
 
      Tang Kohiki 
     
      Fri, 23:41:01
      
     
      Http://www.csdn.net/article/2013-03-01/2814309-mobile-weekly-choose-rub Ymotion-for-ios-dev
      
 

    
    
   
    
 
     Cast nets everywhere, focus on training, king.com subversive game business model
 
      
     
      http://www.csdn.net/article/2013-02-27/2814282-king.com-game-launch 在App Store的Top Grossing排行榜中,Candy Crush Saga已经排到第二位,仅次于Supercell的Clash of Clans,其开发公司king.com也因此名声大噪,并在移动端打败Zynga,它的成功离不开公司商业模式的创新:发布三部曲+高质游戏+顺势而行。 
 
      Chen Xuten Nine 
     
      Fri, 2013 10: 49:52
      
     
      http://www.csdn.net/article/2013-02-27/2814282-king.com-game-launch
      
 

    
   ...
  
 

I want to use a regular to divide the contents of the above into two parts.
The two parts separated from the blank lines are:
1. Responding to basic information
http/1.1 Okserver:nginx/0.7.68date:sat, 07:44:57 gmtcontent-type:application/rss+xml; Charset=utf-8transfer-encoding:chunkedconnection:keep-alive

2. Response Content
3ab4
 
  
   
   <title>CSDN Mobile Channel (info)</title> 
   
    
   Http://mobile.csdn.net 
   
    
     Open Platform
    
    
   
    
     Sat, Geneva 15:44:50
    
    
   
    
 
     Mobile Weekly: Why did I abandon objective-c and choose rubymotion?
 
      
     
      Http://www.csdn.net/article/2013-03-01/2814309-mobile-weekly-choose-rubymotion-for-ios-dev 我们为您精心准备了CSDN移动频道本周最精彩的热点新闻,开发者直言RubyMotion优与劣,讲述为何弃用Objective-C而选择RubyMotion;出生贫苦的Minecraft开发者Notch大神特立独行,始终秉承开放的游戏开发理念;移动互联网大潮来袭,国家级老牌媒体China Daily将怎样拥抱新媒体时代? 
 
      Tang Kohiki 
     
      Fri, 23:41:01
      
     
      Http://www.csdn.net/article/2013-03-01/2814309-mobile-weekly-choose-rub Ymotion-for-ios-dev
      
 

    
    
   
    
 
     Cast nets everywhere, focus on training, king.com subversive game business model
 
      
     
      http://www.csdn.net/article/2013-02-27/2814282-king.com-game-launch 在App Store的Top Grossing排行榜中,Candy Crush Saga已经排到第二位,仅次于Supercell的Clash of Clans,其开发公司king.com也因此名声大噪,并在移动端打败Zynga,它的成功离不开公司商业模式的创新:发布三部曲+高质游戏+顺势而行。 
 
      Chen Xuten Nine 
     
      Fri, 2013 10: 49:52
      
     
      http://www.csdn.net/article/2013-02-27/2814282-king.com-game-launch
      
 

    
   ...
  
 


Reply to discussion (solution)

You're not going to read the HTTP header, okay?

You're not going to read the HTTP header, okay?
I need a head message. Because transfer-encoding:chunked

$arr =preg_split ('/(<=connection:keep-alive) \s+/s ', $s);p rint_r ($arr);

I need a head message. Because transfer-encoding:chunked this transfer-encoding:chunked is meaningless to you.

PHP code?12$arr=preg_split ('/(<=connection:keep-alive) \s+/s ', $s);p rint_r ($arr);
Not all of the response header information is connection ended.

Reference 2 floor Pktmalaha reply: I need the head information. Because transfer-encoding:chunked this transfer-encoding:chunked is meaningless to you.

Of course I need it. Because if chunked needs unchunk,

Reference 2 floor Pktmalaha reply: I need the head information. Because transfer-encoding:chunked this transfer-encoding:chunked is meaningless to you.
Header information I'm sure I need it. Because my code needs it to do a lot of things.

Reference 4 Floor xuzuning reply: Reference 2 floor Pktmalaha reply: I need the head information. Because transfer-encoding:chunked this transfer-encoding:chunked is meaningless to you.

Of course I do. Because if chunked needs unchunk, then that means you have to analyze your head back.
If so, it should not be a regular thing!
You need to read the header information line by row until you read the empty line (head end)

This is not a regular job.

Two-part intercept from the first empty line, right?
And then analyze the head yourself.

Two-part intercept from the first empty line, right?
And then analyze the head yourself.
I don't know how to do it. is to intercept from a blank line. Can you provide the regular?

This post was last edited by xuzuning on 2013-03-04 08:29:12
Reference 6 Floor Pktmalaha reply: Reference 4 floor xuzuning reply: Reference 2 floor Pktmalaha reply: I need the head information AH. Because transfer-encoding:chunked this transfer-encoding:chunked to you and ...

I need the head information to do the work of the head information, need the text to do the work of the text. And I mixed it with the contents of the socket. Is it now possible to separate the two with regular? I need you to provide a regular expression. Instead of telling me what I need


Explode ("\r\n\r\n", $str, 1);

Explode ("\r\n\r\n", $str, 1); See what I need is a regular, explode's first parameter is the regular?

If the response data you get is the response header + Response topic, the HTTP response header ends with two blank lines. Can be used as a basis for separation.

In another way, there are many class libraries that can get response headers and response topics separately. such as Httplib

Reference 12 Floor Helloyou0 's reply: Explode ("\r\n\r\n", $str, 1); see what I need is the regular, explode's first parameter is the regular?
It is not efficient to suggest that you do not use the regular.

It's not going to be able to intercept two parts with a line break.

If you want to use regular, try the following notation

$arr = Preg_split (' #^[\r\n] #m ', $text);p Rint_r ($arr);

You have to use the regular. What's the reason?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.